Newbie: Canonical way for getting this layout (screenshot)
-
Hi all,
what is the canonical way in Qt for getting the following layout without trick or workarounds?
- Table A can shrink and grow, horizontally and vertically
- Table B can grow and shrink horizontally only while the height is fixed (no vertical resizing allowed)
- Buttons must be aligned as in the picture: the top one must be aligned with table b on the top. And obv., they must not resize.
Could you please share your ui file?
Thank you!
Edited

-
Hi,
I can't share any Ui file as I don't use Designer.
However, you can do it using code.
You already know the widgets you need.
From the top of my head:
Set a fixed height on B.
Your two buttons should go in their own vertical layout to which you add a stretch after adding the second button so they are pushed up. B and the buttons layout go into a horizontal layout and finally, A and the horizontal layout go into a vertical layout that you set on you main widget.
When adding A to the vertical layout, use a stretch factor of 1 so it will get more space than what is below. Do the same for B when you add it to the horizontal layout so it should also take more space that the buttons.
-
Hi,
I can't share any Ui file as I don't use Designer.
However, you can do it using code.
You already know the widgets you need.
From the top of my head:
Set a fixed height on B.
Your two buttons should go in their own vertical layout to which you add a stretch after adding the second button so they are pushed up. B and the buttons layout go into a horizontal layout and finally, A and the horizontal layout go into a vertical layout that you set on you main widget.
When adding A to the vertical layout, use a stretch factor of 1 so it will get more space than what is below. Do the same for B when you add it to the horizontal layout so it should also take more space that the buttons.
Your two buttons should go in their own vertical layout to which you add a stretch after adding the second button so
they are pushed up. B and the buttons layout go into a horizontal layout and finally, A and the horizontal layout go into a
vertical layout that you set on you main widget.Already done. What you get at the end is that the vertical spacer grows, which in turn the vertical layout grows, which in turn the horizontal layout grows up to the half of the main window. The top half is take by table A.
When adding A to the vertical layout, use a stretch factor of 1 so it will get more space than what is below. Do the same >for B when you add it to the horizontal layout so it should also take more space that the buttons.
As far as I've understood, with stretch you set a different factor of growing than what is the default. But I don't care
about table A, it can grow or shrink, table B must grow or shrink only horizontally and not vertically.
Do you talk about vertically stretch in you comment I guess, right?Thanks
-
C cdvo has marked this topic as solved on