Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] Designer: how to make a form layout auto adjusting its size?
fluca1978 last edited by
I'm designing a window with the QtDesigner. The window is organized into two columns, each one managed by a specific layout (vertical layout on the left, form layout on the right). I'd like to have the right column to auto-adjust its size when the window is resized too, but actually this does not happen. How should I place components and layout in the window?
If you're using QMainWindow, remember to call setCentralWidget() with your main layout - it will stretch to cover the whole main window, and resize with it.
Then, to make only one of the layouts resizable, you'll have to dive into layout's properties, set sizeConstraint to desired. You can also adjust widgets' (ones inside your layout) size policy with setSizePolicy(). More:
Oh, and I've mixed a bit things from code itself with things from QtDesigner.
andre last edited by
The trick is this:
In your form, place two QWidgets, one for each of the pannels. Put those two widgets in a horizontal layout. now, set the size policies of the widgets, so that the left one is fixed, and the right one is minimumExpanding. Next, put the contents of your form sides inside these widgets, and again apply a layout to each of the created "panels". Note that you can also use some other widget (like QFrame or QGroupbox) instead of QWidget if that suits your needs better.