Qt World Summit: Submit your Presentation

[SOLVED] Designer: how to make a form layout auto adjusting its size?

  • Hello,
    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?


  • Moderators

    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:

    "QWidget doc":http://developer.qt.nokia.com/doc/qt-4.7/qwidget.html#id-caf2280e-729f-43c8-9f95-f9415d0f5a33



    Oh, and I've mixed a bit things from code itself with things from QtDesigner.

  • 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.

Log in to reply