 Hey everybody, it's Brian. This is our third cute video using C++. Today we are going to build a GUI application. Just a very simple one. I want to show you what it looks like. And we'll call this GUI. Hit next. And then you see class name, main window, base class, queue, main window, header, source. What are all these things? Well, let's go over them real quick. Main window, this is going to be the name of your class. What this works is it creates a form and it creates a class to go along with it. If you're used to visual basic or C sharp, this is a familiar concept to you. Okay, base class, queue, main window. You can also do queue widget, queue dialogue. We'll cover those in a later tutorial. But today just queue, main window. And the header file will generate the source file and generate form. Yes, keep that checked. Form file name, main window dot UI. UI, that is the extension that the cute creator uses to create the form files. Version control, we choose none. And select the version of cute you wish to use. And wow, we get a lot of stuff here. Let's move some stuff around, see if we can make this a little more visible for you. This is your form. I realize it's kind of cramped due to some space limitations here. Here is your controls. Here are your actions down here. We'll cover actions later. Here's your object explorer and here's your properties window. Now I must apologize for the cramped space here. I try to keep these videos small in pixel size. That way it doesn't take forever to upload them. Alright, and go here and click edit. I want to kind of show you. You see how it instantly turns into an XML file. That's really all UI file is as an XML file. Let's go to design mode and there's your form again. So if you're sitting there working and suddenly it turns into XML, have no fear, that's what's going on. Alright now, this is the structure of your program. Notice it's got the profile. We'll cover that in the last tutorial. Here's your UI file, which is your form itself. Your main window dot H and main window dot CPP. And here's main dot CPP. Let's open main up. You can see this is a standard C++ file. Here's our main function right here. You see it's just generating a Q application calling A with the args. Main window W, W dot show, return A dot exec. This looks strikingly similar to the console application that we created. Except for now we've got a main window and we're doing main window show. What that is doing is generating this main window class that we created. Remember it wanted a class name. Let me pause the video for a minute. My cat needs some attention. Okay, I'm back. Sorry about that. Cat for whatever reason leaves me alone until I start recording and then just wants my attention. Alright, in the main window dot H you can see that we are including the namespace UI. That goes into your user interface elements in the main window dot UI. We'll show you that here in a second. Class main window and here's your main window class. You see we're adding this macro Q object. Remember our last C++ tutorial was the macro tutorial. That's really all that does is converts this into a Q object. Everything in Qt stems from what's called a Q object. You see how this main window is a Q main window. Well a Q main window is actually a Q object under the hood. But in order to be a Q object you have to have this macro which converts it. It gets into some complex stuff in the background but really all you need to know is at the base level everything in Qt is an object similar to Java or dot not where everything is an object. Alright, moving right along here is your public and here are your private. You see here is UI namespace main window and there is a pointer to UI. Here's your implementation file. Here's the constructor and you're saying UI set up UI this. Basically it just creates the user interface and then main window delete UI. One thing you should note about Qt. This is why this framework is so powerful and so popular is that it makes pointers insanely easy to work with because they delete themselves. Now I don't mean the pointers delete themselves. I mean everything deletes themselves. For example, let's go to our main window here and let's just want to filter this out. We type button and you notice how it filters the list automatically. We'll just add a push button here. Go over here, main window oops. Now what it didn't do was add a reference to this button. You notice how your class isn't mocked up with the pointer to a button and all this other hoopla. But if you go in here you can go UI push button, set text, hello. The UI actually holds a reference to the push button class which you know if you hover over you see this little Q push button F1. If you press F1 it'll actually take you to the help file for the Q push button. That is a very helpful feature. Admittedly they've kind of taken that concept from other IDEs. But anyway, let's just run this and let's see it work. I want to show you a couple neat things about the Q forms. Here is your main window. There's your button with absolutely zero coding. You have a button positioned on the form. Some things you should note is you have a status bar and a toolbar. We didn't add anything to them. But they're there. Here's your toolbar. You notice how you can actually move this toolbar around. You can set the toolbar there. You can actually detach it. Let's see if it'll detach. It's right there. There's nothing on it but believe me it detaches. You get all that for free and we're going to cover all that later in other tutorials. The whole point of this tutorial was just to get you familiar with the very bare bones elements of a GUI programming Qt. Here's your button and let's close this. Let's actually make that button do something. Go back to your design mode and up here you have these little things. Edit widgets. Edit signals and slots. Now when you click edit signals and slots you notice how things change when you mouse over them. Let's actually mouse over the button. Click and drag and then just unclick over the form. You get this little configure connection. Select clicked and then select show signals and slots inherited from Qidget. In the main window we're going to choose close. What we're saying is we're connecting the push button to the main windows close. When they press click it is fired and the close function is called. You can see how that's graphically represented. You can do that programmatically too but you can do it graphically. It's just easier to learn in the very beginning to do it graphically. Let's go back here and just want to tweak a little something here. Let's just change the text to close. Just to clean it up a little bit here. When you run this and you click close now the form closes. That's called the signal and slot method. That's not unique to Qt programming. That's actually a concept in C++ especially if you use the boost libraries. Signals and slots are like events in Java and .NET. A signal is emitted. That's an event being fired and it's consumed by a slot. The signal here is quickly clicked and the slot is closed. Signals and slots must have the same arguments. You can't do push button with an argument of one to close with no arguments. You'll get a big error message and bad things happen. I wanted to show you those bare bones elements. That's really it. It's very simple. Very easy to use and very easy to understand. Controls. There's a wealth of them here. Just add them in and see what you can do. This is Brian. Thank you for watching. I hope you found this video educational and entertaining.