Search code examples
qtlayoutpyqt4qt-designerqtabwidget

How to set child windows size auto resize with respect to its parent window in PyQt4?


My pyQt4 application have main dialog and it content tab control then sub component in it.

What I want is, when user clicks on maximize button or resizes main window then tab control size as well as its component locations should be auto updated.

like horizontal resizeable, vertical resizeable properties in java swing application.


Solution

  • If you created your dialog in Qt Designer, then make sure you have set all the layouts correctly.

    To start with, right-click each tab of your tab widget, and then select Layout/Layout in a Grid from the menu. There's also a button on the toolbar that does the same thing (the icon is a grid of little blue squares).

    Once you've set the layout on each tab, do the same thing for the main Form as well.

    Note that it is sometimes easier to select and right-click the items in the Object Inspector than the Form itself. The Object Inspector also shows an icon next to each item in the Form that been given a layout.

    Once you've set all your layouts, use Form/Preview... to check that everything works as you expected.