 Everybody, it's Brian. This is our fifth Qt tutorial. Using C++ today, we're going to discuss different window types and how to show them. So just go to File, New. We're going to do a Qt C++ project, a GUI application. And let's just give it a path. Give it a name. We're just going to call this MyWindows. And be sure to give it a base class of Qt MainWindow. Choose your framework version. And sure enough, our main window is created. Now, one thing you'll note is this is the exact same thing we've seen before. You've got Menu, Toolbar, and I don't know if you can see it down here, but we have a status bar. And we have ActionWindows. And let me get that so this has expanded a little bit. Now, this is the Qt MainWindow. What is a MainWindow? Well, a MainWindow is what you're looking at right now. Qt Creator was actually built using Qt. So this big window, Qt Creator, with all these buttons and menus and everything, this is actually a Qt MainWindow. Now, we're going to discuss later what's called a dialogue. So when you say about Qt Creator, this is a dialogue. And then you have things like this button, this picture, and these little things. These are called QWidgets. Now back to our MainWindow. Just select Menu, type File. We're going to actually make a Menu item. And we're going to say New Window. Notice how when you do that, it creates an action down here. And if you kind of expand this out, it says Action New Window. What is an action? You see it here. You see it here. Well, what you can do is you can take this action, drag and drop it onto the toolbar. And you can give it like a picture and all sorts of other interesting stuff. Make it checkable, shortcuts, all that. But for this tutorial, just drag and drop it on the toolbar. So now you have it in two locations. Now what an action does, it allows you to trigger an event. So right-click it in the Action Window, go to Slot, see where it says Triggered. Just hit OK. And it generates the code right here. So when you click either the Menu item or the toolbar item, it's going to trigger this bit of code right here. Now let's just save our work, run it. Just want to show you what this looks like. Now when you click, nothing happens because there's nothing in our code. But you can see how the action is reused. And you have done zero coding to make that happen. You can also take this toolbar and drag it around the window, attach and detach it. You can even detach it right off the application and reattach it back in. Now let's go into our form, the main window UI. And let's just drag and drop a plain text edit on there. Now a plain text edit is a big text editing field, similar to what you see right here. Let's go into our main window. Let's go up to the Creator actually. And we're going to do Set Central Widget. And we're going to say UI, plain text edit. Now what does that do exactly? Well the typical role of a main window is to display a central widget or like an editor. So that's exactly what we're doing is we're saying the central widget is the plain text edit. So it'll take up the majority of the screen space on that window. And sure enough, there's our new window. And we have a text editor built right in as scroll bars and all sorts of other goodness. And let's just, you know, watch to see it word wraps and scrolls. Pretty neat, huh? That is the Q main window and its basic functionality. Now what we're going to discuss is model and model less dialogues. There's only one type of dialogue, but there's different ways of showing them. So let's just right click on forms, add new, select cute, and select cute designer form class. Now what are these other things real quick? A designer form is just a form without a class behind it. So it's essentially useless for us. Resource file holds things like strings, pictures, things like that. We'll get into that in another tutorial. And cute QML file, that's something we'll discuss much, much later. But for now, just do a cute designer form class. And then I'm not sure if this is on every operating system, but on the Windows version of cute creator, you can do a dialogue with buttons, with buttons on the right without main window or widget. We're just going to do a dialogue without buttons. You can set the different sizes. We're just going to leave the default size. And let's just call this myDialog. It'll create a myDialogH, myDialogCPP, and a myDialogUI. Now the UI is the actual form that you can design on. And click finish. And here is, in all our glory, our dialogue. And sure enough, you can put different controls on there. Let's actually add a button. Yeah, you can just drag and drop controls around. Do pretty much whatever you want. We'll cover all that in other tutorials. But for right now, we're just concerned with how do we show these? Let's get that out of there. Now remember back here in our action, we have our onActionNewWindowTrigger. That's when we click that new action that we created. One thing we need to do first is include our file. Remember, we're in C++. Include myDialogH, myDialog, and we're just going to call it mDialog. Now there are two ways of showing this. Model and ModelS. So what we're going to do is we're going to do mDialog. SetModel, and we'll say true, and then exec. What this will do when we run this, after it compiles and builds, of course, this may take a bit of time depending on what sort of machine you have. When you click your button, it's going to call that action, the onActionNewWindowTrigger, and it creates your dialogue. Now this is Model, meaning you cannot click off and interact with anything else in the application. You can only interact with this dialogue. Let me pull that app back up here. So you can't go over here and interact. You can only close the window or do whatever the window wants you to do. There's another way of doing this called ModelS. Now you may be thinking what you do is you set it to false. Well, let's try that. Let's run it and see what happens here. Run, and you see it's still Model. Well, that doesn't help us much. So some of you out there have probably gotten the idea that you're going to do something like this, because I know you've been smart and you read ahead and you realize there's a show function. Now when you run the show function, unfortunately, it's not very helpful. The window appears and disappears. I don't know if the video is vast enough to catch it, so I'm going to click it a few times just to see if you can catch that window. What happens is the window appears and disappears. Remember, we're in C++, so you have what's called a stack and a heap. This is the stack, the heaps off in memory. So when you run this, you're creating this object, you show it, but then the function immediately goes out of scope and moves on to something else, so it's destroyed automatically. So if you want to show this and keep it open, go into mainwindow.h. We're going to need to also include, help if I could spell include, and we're going to give it a pointer back in here. And let's just get rid of this stuff. And we're going to say, equal new, my dialog. And give it a parent of this. What that will do is it'll say that the Q main window that we've created is the parent for the dialog. So when the Q main windows close, the dialog will also be destroyed and memory enclosed. So you don't have to do any real memory management here. Then you can say show. Let's run this. And here's our other dialog. And you notice how we can interact with both windows at the same time. You can even spawn multiple windows and interact with any of them however you want. Pretty interesting stuff here. So once again, what we've covered is the Q main window. For example, you're seeing it in this tutorial, this Q creator and dialogues. For example, this about window. This is Brian. I thank you for watching. I hope you found this video educational and entertaining.