QButtonGroup at least one button must be checked.
-
I have a QButtonGroup of QCheckboxes and I want to ban unchecking all QCheckBoxes. At least one must always be checked.
-
@jsulm I am saying that at least one must be checked. Not saying that only one can be checked.
Well what I did is:
- check when all are checked off
- when it is remove the button from the group to prevent it from triggering the signals
- check the button
- add it back to the group
Is there no other way?
-
@jsulm I am saying that at least one must be checked. Not saying that only one can be checked.
Well what I did is:
- check when all are checked off
- when it is remove the button from the group to prevent it from triggering the signals
- check the button
- add it back to the group
Is there no other way?
@gozag You can connect a slot to https://doc.qt.io/qt-6/qbuttongroup.html#buttonToggled In that slot if "checked" is false check all other buttons. If all other buttons are also not checked then check the button (https://doc.qt.io/qt-6/qabstractbutton.html#checked-prop).
Not sure there is an easier way.
-
@gozag You can connect a slot to https://doc.qt.io/qt-6/qbuttongroup.html#buttonToggled In that slot if "checked" is false check all other buttons. If all other buttons are also not checked then check the button (https://doc.qt.io/qt-6/qabstractbutton.html#checked-prop).
Not sure there is an easier way.