Adding signal on table items
-
Hi,
I've built a QDialog with Qt 4 Designer that contains a QCheckBox that I want to enable for checking depending on a specific number of QTableWidget items being checked. I know I need to work with the signal system but the problem I have is that the QTableWidget in the .ui file is empty so in Designer I can only emit signals like itemClicked and e.g. click my QCheckBox.
After loading the ui file, I populate the QTableWidget in Python with the first item on each row being checkable. What I need to do is enable the QCheckBox if two of my rows have their first item checked. If I could count the number of checked rows on each click and then decide what to do with the QCheckBox, that would be great. Here is what I need to do :
if nb_first_row_cells_checked == 2:
chk.setEnabled(True)
chk.setCheckable(True)
chk.setCheckState(Qt.Unchecked) # User can check
else :
chk.setCheckState(Qt.Unchecked) # Force uncheck if nb !=2
chk.setCheckable(False)
chk.setEnabled(False)Do I need a separate class to do that ?
TIA,
Yves