PDA

View Full Version : [SOLVED] QCheckBox Tristate



ToddAtWSU
15th January 2014, 20:13
I have a Properties table I am creating and I have some fields that are boolean values. I use a QCheckBox for the user to toggle between these values. One of the features I would like to add is to allow the user to select multiple items and checking the checkbox on would set all the selected elements to TRUE for that property.

However, if the selection has some elements with the property as TRUE and other elements have the property as FALSE, I would like to display the PartiallyChecked status to alert the user that not all the elements have the same value. Then when the user modifies this, I would only like them to choose Checked or Unchecked.

So is there a way to make a QCheckBox have Tristate capabilities but to make PartiallyChecked only accessible by the program and not the user?

Thanks and let me know if you need any further clarification!
Todd

EDIT:

I was able to solve this by quickly subclassing QCheckBox and overriding the nextCheckState( ) function to set the check state to Qt::Unchecked if it was Checked, and Checked otherwise.