I currently have a setup where I am trying to embed checkboxes in a QTableWidget
. I am setting the checkbox cells in the following way:
chkbox1 = QTableWidgetItem()
chkbox1.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
chkbox1.setCheckState(Qt.Unchecked)
chkbox2 = QTableWidgetItem()
chkbox2.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
chkbox2.setCheckState(Qt.Unchecked)
self.tblData.setItem(i, 0, chkbox1)
self.tblData.setItem(i, 1, chkbox2)
This seems to work fine, however I cannot seem to catch the signal emitted whenever a box is checked or unchecked. I've tried:
self.connect(self.tblData, SIGNAL('itemChanged(QTableWidgetItem)'), self.updatePlot)
But this doesn't do anything. As a test, I've connected a button click to the same method, and it works fine, so I know it's just that I'm missing a signal.
From what I understand, itemChanged
should be emitted any time any data is changed, and isn't changing the checkbox state changing the data?
Thanks in advance for you help.
Signal signature is wrong. It should be
itemChanged(QTableWidgetItem *)
(Note the*
):or better, use the new style connections:
I guess you have to use ItemClicked signal instead. Since itemChanged signal is emitted when the data is changed and data is the text perhaps.