I have a QWidget in a QMainWindow. The QWidget contains two other widgets and a gridlayout:
def __init__(self):
self.main = MainWidget()
self.CreateActions()
self.CreateMenus()
self.setCentralWidget(self.main)
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.main = MainWidget()
self.CreateActions()
self.CreateMenus()
self.setCentralWidget(self.main)
To copy to clipboard, switch view to plain text mode
def __init__(self):
self.tree = TreeArea(self)
self.display = DisplayArea(self)
gridLayout.addWidget(self.tree, 0, 0)
gridLayout.addWidget(self.display, 0, 1, Qt.AlignCenter)
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)
To copy to clipboard, switch view to plain text mode
Here is my TreeArea and DisplayArea:
def __init__(self, parent):
labels << "Type" << "Name" << "Node ID" << "Device Type" << \
"Address Type" << "Value"
self.setHeaderLabels(labels)
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)
To copy to clipboard, switch view to plain text mode
def __init__(self, parent):
self.setAcceptDrops(True)
class DisplayArea(QFrame):
def __init__(self, parent):
QFrame.__init__(self, parent)
self.setAcceptDrops(True)
To copy to clipboard, switch view to plain text mode
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.
Bookmarks