PDA

View Full Version : Having resize problems with QGridLayout



di_zou
10th December 2009, 15:49
I have a QWidget in a QMainWindow. The QWidget contains two other widgets and a gridlayout:



class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)

self.main = MainWidget()
self.CreateActions()
self.CreateMenus()

self.setCentralWidget(self.main)




class MainWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.tree = TreeArea(self)
self.display = DisplayArea(self)

gridLayout = QGridLayout()
gridLayout.addWidget(self.tree, 0, 0)
gridLayout.addWidget(self.display, 0, 1, Qt.AlignCenter)


Here is my TreeArea and DisplayArea:



class TreeArea(QTreeWidget):
def __init__(self, parent):
QTreeWidget.__init__(self, parent)

labels = QStringList()
labels << "Type" << "Name" << "Node ID" << "Device Type" << \
"Address Type" << "Value"

self.setHeaderLabels(labels)




class DisplayArea(QFrame):
def __init__(self, parent):
QFrame.__init__(self, parent)

self.setAcceptDrops(True)


When I run this, the TreeArea takes up the whole widget. How do I set it so that the TreeArea takes up half the widget and the DisplayArea take up the other half? Also I want it so that when I resize the main window, all the proportions stay the same.