 Hey everybody, this is Brian, and this is our sixth Qt video with C++. Today we're going to be going over some more GUI elements. So let's just go File, New, and we're going to say Qt C++ GUI Project, and say My GUI, and let's go Test. And for this tutorial, let's actually just select Qt Dialog instead of QMainWindow. Now some of you are probably going, okay, why did you just select Qt Dialog instead of QMainWindow? I don't want the UI elements like the toolbar and menu bar to really get in the way. I just want to focus on a very simple dialogue. I want to show you a few tricks. So over here on the left, these are your widgets. You can either scroll down and pick the one you want, or you can just start typing it in the name and it will auto-filter it. For example, here's Label. We want a line edit and a button. Actually, let's just grab a couple of buttons here. And you drag and drop and just place them wherever you want them on the form. Now this is all kind of haphazard and it looks really hokey. And I should back up and say I'm also assuming that you know what these are, a label just displays text, line it, it allows you to type it in, and buttons you push them. And you can actually, you know, double click the button and fill in the text. So we're going to say this dialogue just simply wants your name. Well, let's make this a little prettier. That's where layouts come in. Select the label and line edit, and then you have these layouts up here. That's what these buttons are. Go ahead and select the horizontal, or you can press just Ctrl H and it'll lay that out. And then select your buttons. And same thing, you notice how it lines them up, snaps them together. And select the form and, or I'm sorry, select the dialogue and you can see you can still do even further. So select the vertical layout. Now what that does is it lays them out nice and neat. The reason why you would do this is simple. Cute is cross-platform. The way it's rendered in Windows is different than it's rendered in Linux, in Unix, Solaris, I mean, I don't know, I don't know. So you use layouts. That way the code will automatically move and resize the widgets as needed per the operating system that it's being compiled and run on. Another little thing I should show you is a spacer. Say we want these buttons over to the right, just take a horizontal spacer and drop it in, and it automatically moves and pads it. Now you may be wondering how do these controls know how to do all this. Well, you just click a button here and you see this little thing called size policy. That's going to be kind of your homework is to play around the size policy and learn some of these things. But you can set like a minimum size, a maximum size, a base size, and the size policy. All right, now let's just resize this a little bit more. You've worked with edit widgets. You've worked with signals and slots. Let's actually just create a signal slot and we'll say cancel and we're going to do clicked show and we're going to say close and for the OK button clicked and we're going to say accept. That is how you would determine whether the dialogue is just closed or accepted. Then you have these other buttons like this one edit buddies. What are buddies? A lot of people don't really understand buddies and what they do. What a buddy does is allows one control to accept the input for another controls. Let's just say name label and select that to the line at it and what that does is if the label had focus, for example, if you had a underscore under the end, so control and it would automatically set the focus to this line at it. A lot of people don't really understand that. It's not very well used and the tab order, this discusses the tab order and you can just click these around and do what you want to do with them. Just double click it so it changes the order. So we want OK to be one. We want cancel be two and that to be three. Let's play around with this. Let's say we want that to be one, this to be two, that to be three. You can see how you can very quickly and graphically change the tab order. You can set all that programmatically too. Select the edit widgets or F3 and let's save our work and run it. Let's look at our beautiful little dialogue and all its glory. You notice how it's automatically set to the line at it. We hit tab, it goes to the button. Tab again, it goes to cancel. Tab again, it goes up here. And if you hit either one of these buttons, it'll close the form. This one just closes it. This one accepts and close. So that in a nutshell is widgets, tab orders and buddies. Now you should know you can do all this programmatically and if you look over in the object explorer here, let me actually expand this out a little bit. You can see how it's actually filled all these in for you. So you don't have to do it through code. But you can actually go in and use like a Q horizontal layout and Q vertical layout and Q grid layout. We'll go over those in other tutorials, but I wanted to show you how to very quickly and rapidly graphically build a GUI application. Another thing you should note is that you can right click on a control and go to go to slot. And that brings up the signal slots mechanism. So let's say we want to, when this thing is clicked, we want to do something and then you would just modify the code for whatever you want to do. Well, once again, this is Brian. Thank you for watching. I hope you found this video educational and entertaining.