di_zou
8th December 2009, 15:51
I have a QTableWidget. The image attached is what it looks like. How do I make it so that when the dialog first starts up, I want it so that the dialog is only wide enough to show the two columns? I also want to make the QTableWidget shorter to get rid of the whitespace underneath the rows. Is there a setting or function I can use for that? This is what I have in the dialog init function. It is in python, but it is fairly equivalent to the C++ code.
self.displayText = QTextEdit(self)
self.labelTable = QTableWidget(1, 2, self)
self.acceptButton = QPushButton(self)
self.acceptButton.setText("Accept")
self.cancelButton = QPushButton(self)
self.cancelButton.setText("Cancel")
buttonGridLayout = QGridLayout()
buttonGridLayout.addWidget(self.acceptButton, 0, 0, Qt.AlignLeft)
buttonGridLayout.addWidget(self.cancelButton, 0, 1, Qt.AlignLeft)
gridLayout = QGridLayout()
gridLayout.addWidget(self.labelTable, 0, 0)
gridLayout.addWidget(self.displayText, 1, 0)
gridLayout.addLayout(buttonGridLayout, 2, 0)
self.setLayout(gridLayout)
labels = QStringList()
labels << "Type" << "Name"
self.labelTable.setHorizontalHeaderLabels(labels)
Also, How do I make the cells not editable?
self.displayText = QTextEdit(self)
self.labelTable = QTableWidget(1, 2, self)
self.acceptButton = QPushButton(self)
self.acceptButton.setText("Accept")
self.cancelButton = QPushButton(self)
self.cancelButton.setText("Cancel")
buttonGridLayout = QGridLayout()
buttonGridLayout.addWidget(self.acceptButton, 0, 0, Qt.AlignLeft)
buttonGridLayout.addWidget(self.cancelButton, 0, 1, Qt.AlignLeft)
gridLayout = QGridLayout()
gridLayout.addWidget(self.labelTable, 0, 0)
gridLayout.addWidget(self.displayText, 1, 0)
gridLayout.addLayout(buttonGridLayout, 2, 0)
self.setLayout(gridLayout)
labels = QStringList()
labels << "Type" << "Name"
self.labelTable.setHorizontalHeaderLabels(labels)
Also, How do I make the cells not editable?