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

Can't tab to last button in QDialogButtonBox

    XMLWordPrintable

Details

    • 773f9ab01 (dev), 2c58f1770 (6.6), d37740437 (tqtc/lts-6.5), 599328845 (dev), fd710fbba (dev), d4f38a363 (dev), d71b73c14 (dev), 09eb99f01 (dev), b30f21468 (6.7), 88ba33442 (6.6), 49bfdf7e6 (6.7), 9720c6c00 (6.6), be80a8315 (tqtc/lts-6.5), 16ab2eba7 (6.7)

    Description

      A dialog that uses QDialogButtonBox, for example QMessageBox, may in some situations end up with a button that can't be tabbed to.

      A test-case is e.g.:

          QDialogButtonBox buttonBox;
          
          auto printFocusChain = [&]{
              for (auto *button : buttonBox.buttons())
                  qDebug() << button->previousInFocusChain() << button << button->nextInFocusChain();
          };
          
          QDialogButtonBox::ButtonRole roles[] = { QDialogButtonBox::AcceptRole, QDialogButtonBox::AcceptRole, QDialogButtonBox::AcceptRole };
          for (auto role : roles) {
              static int i = 0;
              auto *button = new QPushButton(QString("%1").arg(++i));
              button->setObjectName(button->text());
              QObject::connect(button, &QPushButton::clicked, [=]{
                  qDebug() << button->text();
                  printFocusChain();
              });
              buttonBox.addButton(button, role);
          }
          
          printFocusChain();
        
          QTimer::singleShot(200, [&]{
              printFocusChain();
          });
          
          buttonBox.show();
       

      The initial focus chain is:

      QDialogButtonBox(0x10bfa5230) QPushButton(0x10fcf4610, name="1") QPushButton(0x10fcf6750, name="3")
      QPushButton(0x10fcf6750, name="3") QPushButton(0x10fcf5910, name="2") QDialogButtonBox(0x10bfa5230)
      QPushButton(0x10fcf4610, name="1") QPushButton(0x10fcf6750, name="3") QPushButton(0x10fcf5910, name="2")

      but after QFocusFrame is added we end up with:

      QDialogButtonBox(0x10bfa5230) QPushButton(0x10fcf4610, name="1") QPushButton(0x10fcf6750, name="3")
      QPushButton(0x10fcf6750, name="3") QPushButton(0x10fcf5910, name="2") QFocusFrame(0x120c3b2d0)
      QPushButton(0x10fcf4610, name="1") QPushButton(0x10fcf6750, name="3") QPushButton(0x10fcf5910, name="2")

      Interestingly the buttons can all be tabbed to in reverse order (with shift).

      Attachments

        Issue Links

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

          Activity

            People

              axelspoerl Axel Spoerl
              vestbo Tor Arne Vestbø
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are 3 open Gerrit changes