Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.4
-
None
Description
While QActionGroup is exclusive it is not guaranteed that only one action will be checked.
Example:
auto group = new QActionGroup(this); auto action1 = group->addAction("1"); auto action2 = group->addAction("2"); auto action3 = group->addAction("3"); action1->setCheckable(true); action2->setCheckable(true); action3->setCheckable(true); // action2 will be checked in lambda directly connected to action1::toggled signal connect(action1, &QAction::toggled, this, [action2](bool active) { if (!active) action2->setChecked(true); }); action1->setChecked(true); assert( action1->isChecked()); assert(!action2->isChecked()); assert(!action3->isChecked()); // activate lambda described above action3->setChecked(true); assert(!action1->isChecked()); // true. action1 is not checked assert(!action2->isChecked()); // FALSE. action2 is checked assert( action3->isChecked()); // true. action3 is checked
In this example group has 2 different checked actions. Further behaviour of group is invalid.