 So far, we've been working with one dialog. Let's go ahead and take a look at how to work with multiple dialogs to start off We're just gonna make a simple example. Make sure your base class is Q dialog hit next And we have a basic project that we've been working with pretty much since the very beginning of this Let's go and scale this off and let's grab a couple push buttons here and we're gonna say with parents and without parents So what we're gonna do is we are going to make Another dialog and we're gonna pop that dialog open One with a parent and one without a parent because remember the way Q handles memory management is you have a parent child hierarchy So we're just gonna say button with parents and let's make this without parent That way it's pretty obvious. What's going on here? Go to slot and let's go to slot on this one too Save and run and absolutely nothing's gonna happen because we haven't written any code But this is the bare basics of what's going to happen. We're gonna click a button and we're gonna open another dialog Same thing's gonna happen with each button, but there's a profound and subtle difference One's gonna have a parent one's not and I want to show really demonstrate how that impacts your application So let's right-click. Let's go to add new Now you notice how if you're in C++ you'll have class source header go to cute This is where things get a little bit interesting You can have an item model, which is your model view architecture You can have a cute designer form class or just a designer form The difference here is a little challenging to wrap your head around if you do just the form It's just that just the form, but if you have a form class You can actually build the UI and have the classes behind it. You already have it here You have dialogue plus your header and your implementation file. So let's cancel that. Let's go through that one more time So you're gonna go new cute designer form class If you do just designer form, it's just gonna make this dialogue with no class behind it You have some options. You can make it with buttons on the bottom and it gives you a graphical representation Buttons on the right without buttons main widget I'm sorry main window, which we don't want yet and widget which is just well bare basics of everything So we're gonna do a dialogue without buttons Click next You can see how it wants to say hey, what do you want to call this? Well, we already have a dialogue H. So we're gonna call this dialogue, too We're gonna make a header file implementation file and a UI if you don't see these three boxes You're gonna have a bad time because we're not creating everything that we need in the background and Here is our other file or I should say our other dialogue I'm just gonna wire this thing up and let's put a label in here and let's go ahead and right click Let's go to slot And we're just gonna accept that and close it Notice how now we have dialogue dialogue to dialogue dialogue, too, and we have our two user interfaces Seems a little bit confusing the way this works But it kind of makes sense once you really start digging into it I'm just gonna close all these little files here so you can Double-click go into that go back and edit double-click go into this and you can see they're distinctly different All right, let's go back into here And let's go to slot So we've got our with parent and without parent Let's jump into our header here what we need to do because we're going to work with another file is you guessed it We have to include it We're gonna include dialogue, too Now we have pretty much everything we need to work with this dialogue. Let's jump into here And we've got with parent without parent. So let's go ahead and say Dialogue to and we're gonna make this with a parent And we're just gonna say dialogue show And through the magic of copy and paste we're gonna do the same thing here, but we're gonna get rid of this and we're gonna say No pointer And without parent. Let's see what the fundamental difference here is. Let's go ahead and run this With parent. Ta-da. Here's our other dialogue. Now if we click close It doesn't close the whole application. It only closes this dialogue See And we can click this any number of times that we want We're gonna show you how to limit this to just one here in a second But I just want to outline that, you know, you really can just have a whole ton of these windows There are applications where you'd want to do something like that and each one is a self-contained dialogue Without parent pretty much same functionality So what's the fundamental difference here? With parent If I go ahead and close this parent, you see the entire application closes Without parent. Let's do that again. Let's just have two windows here. Let's close this main window. Both of these are without parent Notice how our application is still running and our dialogues are still here. We open this guy first Let's close him. Nope. It's still running So what's happening under the hood here? You can see how this little guy is running and Let's go ahead force quit him. We could have just closed the dialogue But what's really happening under the hood is our main statement We're saying cute application a and then we're making a dialogue show and then we're gonna a exact So what's happening under the hood here is we're smart enough to know or I should say cute smart enough to know We've opened other dialogue. So this a exec is just gonna loop indefinitely until all of them are closed So let's save and run. You can see it's running because this little red guy is lit up We're say without And without let's do that again. I want to kind of get these out of the way here Close our parent Close and watch this red guy Suddenly it knows. Hey, we've exited code zero So cute knows how many dialogues you've opened and it knows. Hey, if there's still one open, we'll leave the application open Let's mix and match them. We'll say with parents And without parent This top one has the parent this bottom one does not let's go ahead and close this And you notice how oh We have some undesirable behavior here. This guy stayed open Pretty interesting how that works. So be very careful when doing that. Now. The other thing I want to point out here Is if you were to just make a dialogue and I see this constantly And you make it on the stack Not as a pointer What do you think's going to happen here? Well, this goes back into our conversation about scope What's going to happen is we're going to click this button. It's going to say make a dialogue show it and then instantly drop out of it save and run Notice you can click this all day long. There's no dialogue Actually to be brutally honest every time you click this button. You see I'm clicking away We're creating another dialogue in the background, but it's instantly going out of scope And then c++ is deleting it because we're doing this on the stack That's why it's got to be a pointer Let's fix this boy. I screwed that up. There we go Now that it's a pointer, it'll work as expected So if you're ever working with The dialogue or a widget and you want to show it and nothing seems to happen Make sure you're using a pointer. Otherwise, as soon as this goes out of scope It's going to do automatic memory management and clean it up and destroy the object for you I hope you enjoyed this video. It's part of a larger project out of you to me called acute widgets for beginners with c++ This is a large course with 73 lectures and 17 hours of video footage This course covers everything from what is a widget all the way down to complete example applications Using the skills you've learned in this course Sorry, there's no qml in this course. This is strictly acute widgets I will make a qml course later on, but this just focus on widgets from a beginner's perspective Even those as a beginner's course you do need to have some fundamental information available You need to know c++ and the acute core libs I do have some courses available out on utomy acute core beginners intermediate advance It's not necessary. You take these courses, but it is highly recommended And as always i'm available out on the void realms facebook group along with 3000 other programmers. See you there