 Hey everybody, it's Brian and today is our 8th Qt video with C++. Today we're going to be going over layouts and how to do them via code. But what you see before you is the minimal application of very bare bones that we've been working with. Include Qt application. We have our main function and we're just doing a very basic application loop here. Alright, now moving right along. First thing we need to do is include and we'll say whoops, I hit the wrong button here. Sorry about that. Cue push button. And let's do include Cue Hbox. Hbox layout. And let's actually include I cannot type today. Wow. Cue Vbox layout. Now what is Cue Hbox layout and Cue Vbox layout? Well, as you might have guessed, Hbox layout is a layout but it's horizontal and Vbox layout is vertical. And we'll show you these here in just a second. First we got a bit of coding to do. One thing about layouts is they are not technically widgets so you can't show them on the screen. So what we need to do is create a Cue widget and we'll call it window. Cue widget. And this is what we're going to end up showing here. So we'll say window. I forgot my pointer. That would probably be helpful. Now when you run this, all you're going to get is a very big window because it's got no layout, no controls on it, no nothing. It's just your basic widget. So Cue just shows it in the most obnoxiously large size it can possibly think of. Let's actually add set window title. This is how you change the title of the window. Just kind of goofing around here. Alright, let's get down to business. We're going to make a few push buttons here. So we'll say Cue push button button one equal new Cue push button. And we're going to give it just the text of one. Let's make a couple of these. Let's actually make three of them real quick. Through the magic of copy and paste we can make three of them very quickly. Alright two and three and let's change the text accordingly here. Alright, now that we have our buttons out in memory, we need to put them in a layout and then assign the layout to the widget. So let's go Cue hbox layout. We're going to do a horizontal layout and we'll call this hlayout. I always forget my pointer too. And this is a new cute hbox layout. Now to add those buttons onto this layout, you say layout, add widget, and we're going to say button one. And through, you guessed it, the magic of copy and paste probably indent those correctly. Not that it really matters with C++. I just like to be neat. We'll add those to the layout. And then we will say window set layout and assign our layout. Now quick review before we run this. We are including the correct code and then we are starting our application loop. And what we are doing in the initialization of that loop is we're creating a widget calling it window, setting the title, creating three buttons, creating a layout, adding the buttons to the layout, setting the windows layout to the layout memory. Sounds complex, but you get it. Compile run and that is our horizontal layout. Automatically adds them in. And if you add buttons, it will just keep going and going and going. And when you resize this, you notice how you cannot resize any smaller but you can resize bigger. Let me actually drag this so you can see the buttons expand and that goes with the size policy and size hint of the buttons. Alright, now that's the horizontal layout. Let's do a vertical layout. So let's go Q VBoxLayout We'll call this VLayout. And as you've probably already guessed what I'm going to do here, Qt is a very intuitive framework and it's very, very easy to work with. Let's just comment that out so you can see what's going on here. And I'm just going to run and compile it. It's pretty self-explanatory as you might have guessed. What it does is it puts it vertically. So once again, this is Brian and we've covered layouts. We've covered the horizontal and vertical and how to add them onto a form and how to add items into the layout. I hope you found this video educational and entertaining and thank you for watching.