Details
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
- is duplicated by
-
QTCREATORBUG-31170 "Change object name" context menu item for UI elements doesn't select current text in dialog
- Closed
-
QTBUG-120049 [REG 6.6.0 --> 6.6.1] Incorrect child widget has focus in dialog by default
- Closed
-
QTBUG-125337 Change in behavior of starting focus on QDialog.
- Closed
For Gerrit Dashboard: QTBUG-121514 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
539303,4 | QDialogButtonBoxPrivate: Refactor ensureFirstAcceptIsDefault() | dev | qt/qtbase | Status: NEW | 0 | 0 |