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. Name will call this GUI. Hit next, and then you see class name, main window, base class, Q 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. The way this works is it creates a form. It creates a class to go along with it. If you are used to visual basic or C sharp, this is a familiar concept to you. Okay, base class, Q main window, you can also do Q widget, Q dialogue. We'll cover those in a later tutorial. But today just Q main window. And the header file will generate in the source file and generate form. Yes, keep that checked, form file name, main window dot UI. That is the extension that Qt creator uses to create the form files. In a version control, we choose none. And select the version of Qt 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 data upload them. All right. And go to who you're 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, is an XML file. You switch mode 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. All right. Now, this is the structure of your program. Notice it's got the profile. We covered that in the last tutorial. Here's your UI file, which is your form itself. Your main window.h and main window.cpp. And here's main.cpp. Let's open main up. You can see this is a standard C++ file. Here's our main function right here. And you see it's just generating a queue application, calling A with the args. Main window.w.w.show, return.a.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. Now 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. The cat for whatever reason leaves me alone until I start recording and then just wants my attention. Alright, in the main window.h, you can see that we are including the namespace UI. UI, that goes into your user interface elements in the main window.u.i. 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 queue object. Remember our last C++ tutorial was the macro tutorial. That's really all that does is convert this into a queue object. Everything in queue stems from what's called a queue object. You see how this main window is a queue main window. Well, a queue main window is actually a queue object under the hood. But in order to be a queue 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 queue is an object. Similar to Java or dot-net 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 is your implementation file. Here is 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 queue. 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 to delete themselves. For example, let's go to our main window here and let's just want to filter this out. We type button. You notice how it filters the list automatically and we'll just add a push button here. Go over here. Main window. Whoops. Now what it didn't do was add a reference to this button. You notice how your class isn't mocked up with a 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 if you hover over and you see this little queue push button, f1 if you press f1 it will actually take you to the help file for the queue push button. That is a very helpful feature. Admittedly they've kind of taken that concept from other IDEs. But anyways let's just run this and let's see it work. I want to show you a couple neat things about the queue forms. Here is your main window. There's your button with absolutely zero coding. You have a button positioned on the form. Something you should know 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 can move this toolbar around. You can set the toolbar there. You can detach it. Let's see if it will detach. There's nothing on it but believe me it detaches. You get all that for free. 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 bearbond elements of a GUI programming queue. Here's your button. Let's close this. Let's actually make that button do something. Go back to your design mode. 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. Then just unclick over the form. You get this little configure connection. Select clicked. Then select show signals and slots inherited from QIGIT. In the main window we're going to choose close. What we're saying is we're connecting the push button to the main window's close. When they press click or when they press it click 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. Now you click close. Now the form closes. That's called the signal and slot method. That's not unique to QIT programming. It's actually a concept in C++ especially if you use the push libraries. Signals and slots are like events in Java and .NET. A signal is emitted. That's an event being fired. It's consumed by a slot. The signal here is the 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 an argument. You'll get a big error message and bad things happen. Run and short on time but I wanted to show you those bare bones elements. That's really it. It's very simple. Very easy to use. Very easy to understand. Go ahead and play around with some of these other 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.