How to make widget use maximum height
-
wrote on 6 Jan 2021, 07:45 last edited by OpenGL 1 Jun 2021, 07:46
I'm using qt creator and designer to create an app, and so far I have in the MainWindow 4 things:
- a qtreeview
- a group box
- another group box
- a vertical spacer
The treeview is to the left and first groupbox is in the upper right corner, and the other box below and the spacer below that group box.
I selected each group box in turn and clicked "Lay out in a grid" and set "LayoutSizeConstraint" to "SetFixedSize" for them both, so they look very nice and keep their size when resizing the mainwindow.
Then I selected the central widget and clicked "Lay out in a grid".
Now the groupboxes are close to eachother and stay in the upper right corner when resizing the mainwindow, and the treeview changes size to fit as much as possible horrizontaly (great!) but how can I get it to scale vertically and use maximum height?
-
You need to modify sizePolicy of your QTreeView widget and set it to expanding in both directions.
-
wrote on 7 Jan 2021, 06:14 last edited by
Thanks for the suggestion, but it didn't help. It was already set to Expanding in both directions.
-
wrote on 9 Jan 2021, 02:57 last edited by
I solved it by breaking up the layout of the central widget, and putting the widgets to the right (2. 3. and 4.) in a vertical layout, and then add a grid layout in the central widget.
-
Nice, thanks for sharing the solution