diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-02-22 16:16:14 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-03-29 15:31:21 +0000 |
commit | 0dbc575c1a8359534761167a5f5f1e29abedd51d (patch) | |
tree | d1675ab1d58f5540fc1c88a92c1d2046c922b296 /src/quickwidgets | |
parent | b82d5bb4186952d66ebd4a3f6a21c5d9e8705940 (diff) |
Make keyboard events work in QQuickWidget
Right now many cases outside of text input fields are simply broken,
e.g. one cannot use a TableView or other controls with the keyboard.
Removing the seemingly unnecessary focusObject() solves all problems
since this way key events get delivered to the QQuickWidget which in
turn forwards to the QQuickWindow.
Directly routing into the QQuickWindow's focusObject(), which can be
any item in the scene is wrong since it skips a big part of
QQuickWindow's event handling logic.
Task-number: QTBUG-45757
Change-Id: Ie53b9003d156ab019fa4b9cf461e209990e738f7
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/quickwidgets')
-rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 7 | ||||
-rw-r--r-- | src/quickwidgets/qquickwidget_p.h | 2 |
2 files changed, 3 insertions, 6 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index ea02723db8..5d7fb04b9f 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -353,10 +353,9 @@ QImage QQuickWidgetPrivate::grabFramebuffer() return renderControl->grab(); } -QObject *QQuickWidgetPrivate::focusObject() -{ - return offscreenWindow ? offscreenWindow->focusObject() : 0; -} +// Intentionally not overriding the QQuickWindow's focusObject. +// Key events should go to our key event handlers, and then to the +// QQuickWindow, not any in-scene item. /*! \module QtQuickWidgets diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h index 559321cd51..6892e6e0b4 100644 --- a/src/quickwidgets/qquickwidget_p.h +++ b/src/quickwidgets/qquickwidget_p.h @@ -99,8 +99,6 @@ public: void destroyContext(); void handleContextCreationFailure(const QSurfaceFormat &format, bool isEs); - QObject *focusObject() Q_DECL_OVERRIDE; - #if QT_CONFIG(opengl) GLuint textureId() const Q_DECL_OVERRIDE; QImage grabFramebuffer() Q_DECL_OVERRIDE; |