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

[Reg 6.6.0->6.6.2] Focus wrong in dialog with QDialogButtonBox

    XMLWordPrintable

Details

    • All
    • 1b2326062 (6.6.2), 78a330137 (dev), 1e89a6e58 (6.7), 281a41b81 (6.6), 42185e58f (tqtc/lts-6.5)

    Description

      In a dialog with an input field and a dialog button box, the button in the button box gets focus instead of the input field. This is an annoying behavior change in 6.6.2.

      #include <QApplication>
      #include <QDialog>
      #include <QDialogButtonBox>
      #include <QLineEdit>
      #include <QPushButton>
      #include <QVBoxLayout>
      #include <QWidget>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QWidget w;
          w.setLayout(new QVBoxLayout);
          auto button = new QPushButton("Open Dialog");
          w.layout()->addWidget(button);
          QObject::connect(button, &QPushButton::clicked, &w, [&w] {
              QDialog d(&w);
              auto l = new QVBoxLayout;
              d.setLayout(l);
              l->addWidget(new QLineEdit());
              l->addWidget(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel));
              d.exec();
          });
      
          w.show();
          return a.exec();
      }
      

      With Qt 6.6.0, the dialog opens with focus in the input field. With Qt 6.6.2, the dialog opens with focus on the Ok button.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-121514
          # Subject Branch Project Status CR V

          Activity

            People

              axelspoerl Axel Spoerl
              con Eike Ziller
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: