I want to have a small QFormLayout
that grows to fill its parent widget.
I created a new .ui file using the QWidget
template in Qt Designer. I put a QFormLayout
inside that 'window', then put some controls inside that QFormLayout
.
This all works reasonably well, but the QFormLayout
always stays at the size I set in Qt Designer. I would like the QFormLayout
to fill its parent widget and grow/shrink with it.
How can I accomplish that?
Right click on the root widget (easiest in the Object Inspector), and from the bottom of context menu, select Lay out > - Lay out in Grid. Right click on the label, and from Layout alignment > set it aligned to the corner you want.
Once you have add your layout with at least one widget in it, select your window and click the "Update" button of QtDesigner. The interface will be resized at the most optimized size and your layout will fit the whole window. Then when resizing the window, the layout will be resized in the same way.
In Designer, activate the centralWidget and assign a layout, e.g. horizontal or vertical layout. Then your QFormLayout will automatically resize.
Always make sure, that all widgets have a layout! Otherwise, automatic resizing will break with that widget!
Controls insist on being too large, and won't resize, in QtDesigner
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With