Is there a way to define sets of checkable cells in a QTableWidget so that at most one cell can be checked?
Is there a way to define sets of checkable cells in a QTableWidget so that at most one cell can be checked?
Without looking deeper into that I see two options:
1) connect to the table widget's itemChanged() signal and in the slot check if the item is checked and if it is uncheck all that are exclusive
2) derive from QTableWidgetItem, reimplement setData() to intercept Qt::CheckRoleState and do the unchecking in there (or delegate to a class that does it)
Cheers,
_
davethomaspilot (9th August 2014)
Ok, I'll do option 1.
Thanks,
Dave Thomas
#1 not so good, since the itemChanged() slot gets recursively called since the code is unchecked (changing) the item.
Ugh.
Added after 16 minutes:
So, in the slot I check a bool "unchecking". If set, just return.
Set the bool after the text and unset after unchecking all the exclusive items.
Not so bad, but easy to miss when you first implement.
Dave Thomas
Last edited by davethomaspilot; 10th August 2014 at 00:45.
Bookmarks