Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-77980

QActionGroup exclusiveness is broken in some situations

    XMLWordPrintable

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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            niktischenko Nikolay Tischenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes