views:

315

answers:

2

I'm using the Qt Designer.

I want to create a QVBoxLayout which will automatically expand to fill the whole window.

The layout of the QVBoxLayout remains fixed.

How can I cause the QVBoxLayout to expand and fill the entire window through the designer?

A: 

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.

Patrice Bernassola
I ment that when the user resizes the entire window, the vertical layout (and thus its content) will stretch to fit it. I don't care how it looks in the Qt Designer.
Elazar Leibovich
+5  A: 

After creating your QVBoxLayout in Qt Designer, right-click on the background of your widget/dialog/window (not the QVBoxLayout, but the parent widget) and select Lay Out -> Lay Out in a Grid from the bottom of the context-menu. The QVBoxLayout should now stretch to fit the window and will resize automatically when the entire window is resized.

Greg S
Yeah I figured that out. But that's a bad default. What exactly happens when you drag the `QVBoxLayout` to the main window widget?
Elazar Leibovich
Thank you, I've been looking for a solution to this problem as well.
Simon H.