From 0e3ede3d176e062cec5680ca60978af2872b16a3 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 12 Aug 2013 20:25:42 +0200 Subject: [PATCH] Fix ShortcutOverrid for Qt Quick The tryShortcutOverride function needs to be called with the focus object. The same logic is in QGuiApplication::notify. Applications with QGuiApplication would therefore handle ShortcutOverride correctly where QApplication would not allow the override. ChangeLog: Fixed ShortcutOverrid for QtQuickControls. Now it is possible to assign a shortcut such as "b" and still type "b" in text inputs. Task-number: QTBUG-32928 Change-Id: I4f4ab82fd11f45174a4483a01bbbe8143dfe0724 Reviewed-by: Shawn Rutledge Reviewed-by: Gabriel de Dietrich --- src/widgets/kernel/qapplication.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 777342d7ae..b918bdb9e9 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2858,7 +2858,14 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QKeyEvent* key = static_cast(e); #ifndef QT_NO_SHORTCUT // Try looking for a Shortcut before sending key events - if (qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key)) + QObject *shortcutReceiver = receiver; + if (!isWidget && isWindow) { + QWindow *w = qobject_cast(receiver); + QObject *focus = w ? w->focusObject() : 0; + if (focus) + shortcutReceiver = focus; + } + if (qApp->d_func()->shortcutMap.tryShortcutEvent(shortcutReceiver, key)) return true; #endif qt_in_tab_key_event = (key->key() == Qt::Key_Backtab