You need to use QLayout .
You can do this very easily in Designer. Just right-click the form and select Layout and Lay Out Horizontally or Lay Out Vertically - you will need other widgets in the form to see the difference between them. You will see the QLayout added to the Object Inspector, and you can customize its properties as you can using your widgets.
You can also create layouts with code. Here is a working example:
import sys from PyQt4.QtCore import QRect from PyQt4.QtGui import QApplication, QWidget, QTabWidget, QHBoxLayout class Widget(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent)
source share