Reputation: 1972
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.
Upvotes: 1
Views: 9889
Reputation: 120798
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.
Upvotes: 3
Reputation: 5760
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 QPushButton
s 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. QPushButton
s happen to only fill horizontally (unless you set a size policy), but a QTabWidget
will fill all the available space.
Upvotes: 1