Auto-expanding layout with Qt-Designer

前端 未结 5 536
借酒劲吻你
借酒劲吻你 2020-12-12 09:01

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 QVB

相关标签:
5条回答
  • 2020-12-12 09:40

    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.

    0 讨论(0)
  • 2020-12-12 09:46

    Set the horizontalPolicy & VerticalPolicy for the controls/widgets to "Preferred".

    0 讨论(0)
  • 2020-12-12 09:53

    I've tried to find a "fit to screen" property but there is no such.

    But setting widget's "maximumSize" to a "some big number" ( like 2000 x 2000 ) will automatically fit the widget to the parent widget space.

    0 讨论(0)
  • 2020-12-12 09:56

    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.

    0 讨论(0)
  • 2020-12-12 10:00

    According to the documentation, there needs to be a top level layout set.

    A top level layout is necessary to ensure that your widgets will resize correctly when its window is resized. To check if you have set a top level layout, preview your widget and attempt to resize the window by dragging the size grip.

    You can set one by clearing the selection and right clicking on the form itself and choosing one of the layouts available in the context menu.

    0 讨论(0)
提交回复
热议问题