Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.13.2
-
None
-
23b998fa454ca021aa595f66d2e1964da4a119a4 (qt/qtbase/dev) 79008da82d9b5bcb99df88ff8b9dc5e130675e53 (qt/qtbase/5.15)
-
Bug Fixing Week Q2/2020
Description
#include <QApplication> #include <QLayout> #include <QLineEdit> #include <QPushButton> int main(int argc, char **argv) { QApplication app(argc, argv); QWidget window; auto layout = new QHBoxLayout(&window); auto button = new QPushButton(&window); layout->addWidget(button); auto edit = new QLineEdit(&window); layout->addWidget(edit); QObject::connect(button, &QPushButton::clicked, [button, edit] { button->setFocusProxy(edit); }); window.show(); return QApplication::exec(); }
Start this application and press the space bar to make the line edit the focus proxy of the button.
This is now supposed to move the keyboard focus to the line edit, but it happens only partially: you can't enter any text, pressing the space bar pushes the button, and yet the menu key opens the line edit's context menu. Switching to the other window and back fixes that.
The missing part of the new setFocusProxy seems to be updating focus_child of the parent widgets — that's what happens in QWidget::setFocus and QWidget::clearFocus together with QApplicationPrivate::setFocusWidget.
Attachments
Issue Links
- relates to
-
QTBUG-83720 [REG 5.13.0->5.13.1] QWidget::setFocusProxy steals (and breaks) focus from widgets at the end of the proxy chain
- Closed