2 horizontal layouts, 1 with fixed height
-
I'm using Qt Designer to create a page with a navigation bar (using buttons at the top of the page inside a horizontal layout) and a message in the lower horizontal layout. The problem I'm having is the 2 layouts take half of the screen each. I want the top horizontal layout to have a fixed height and the lower one to take the remaining screen. I don't seem to find any property in the horizontal layout that can fix this problem in Design mode.
How can I have 2 layouts, one with fixed size?
Here is an image to help visualize it
-
Hi
you can use LayoutStretch 2,1 to share other than half/half.
That said, you set minimum size on the widget you insert into the layout
so for your design, the top bar,you would set MInimumHeight to say 64
and it would not get bigger.So with layouts, u set constraints on the widgets, not on the layouts.
-
For some reason it's not working so I will list what I do step by step :
-
I have QStackedWidget with contains 2 pages (page 2 is the one that will have the 2 layouts )
-
drag and drop 2 horizontal layouts into page2
-
selected page 2, right-click, choose layout, lay out vertically (at this point each of the layout fill out half of the screen)
-
when I select the top layout and change LayoutStretch to 1, the bottom layout changes LayoutStretch automatically to 0. If I change the bottom layout to 2 and select the top layout to check its value I find that it was automatically changed to 2. If I go back to the bottom layout I find that LayoutStretch is 0.
-
drag and drop a button in the top layout and change it's maximum size to width = 125 and height = 60, has no effect on the top layout, still takes half of the screen.
What am I still doing wrong?
-
-
- You should no drag layout to page. Its rarely use standalone.
Right click is the way to add layout.
Try this
Create page 3. ( so we have clean to play with)
Drag 2 widgets to it.
Right click the page and select the Vert layout.
(widgets should spit it half/half)
Now click on top widget
and set its Maximum Height to 64.
It should be top bar aliek now. place buttons etc in it.ps. and dont worry. layout are kinda strange to learn at first. later they be your best friends.
- You should no drag layout to page. Its rarely use standalone.
-
Using 2 widgets instead of horizontal layouts worked but it has its problems.
First, I like the layout to be wrap around multiple buttons to keep them lined up perfectly.
Second, if I resize the window a few of the buttons disappear.
Is there a way to get around those 2 problems?