1

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.

anils
  • 1,432
  • 5
  • 17
  • 27
  • got solution here! http://stackoverflow.com/questions/3492739/auto-expanding-layout-with-qt-designer – anils Jan 22 '12 at 15:12

2 Answers2

3

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.

ekhumoro
  • 98,079
  • 17
  • 183
  • 279
1

Use a layout such as QHBoxLayout or QVBoxLayout.

from PySide.QtCore import *
from PySide.QtGui import *

app = QApplication([])

win = QMainWindow()

frame = QFrame()
win.setCentralWidget(frame)

layout = QHBoxLayout()
frame.setLayout(layout)

layout.addWidget(QPushButton("Expanding Button"))
layout.addWidget(QPushButton("Another Expanding Button"))

win.show()

app.exec_()

This will add two QPushButtons to a QMainWindow within a QHBoxLayout. This means that they will be beside each other, and they will each fill their half of the window. QPushButtons happen to only fill horizontally (unless you set a size policy), but a QTabWidget will fill all the available space.

D K
  • 4,934
  • 5
  • 26
  • 40