[Solved] PySide 1.1.0: Putting a checkbox in horizontalHeader of QTableWidget
-
I would like to put a checkbox in the horizontal header of my tablewidget. Since the base object type is QTableWidgetItem, I tried this:
@item = QtGui.QTableWidgetItem()
item.setCheckState(QtCore.Qt.Checked)
self.tableWidget.setHorizontalHeaderItem(1, item)
@and I also tried this:
@self.tableWidget.horizontalHeaderItem(1).setCheckState(QtCore.Qt.Checked)
@Neither of them put a checkbox in the horizontal header. Any suggestions on how to get a checkbox in the horizontal header?
-
Thanks, that suggestion worked well. Here's a code sample in case anyone else wants to do something similar:
@class custom_table(QtGui.QTableWidget):
def __init__(self, parent=None): QtGui.QTableWidget.__init__(self, parent) self.chkbox1 = QtGui.QCheckBox(self.horizontalHeader()) def resizeEvent(self, event=None): super().resizeEvent(event) self.chkbox1.setGeometry(QtCore.QRect((self.columnWidth(0)/2), 2, 16, 17))@
The "(self.columnWidth(0)/2)" keeps the checkbox in the middle of the column header.