summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-01-07 14:55:58 +0100
committerMitch Curtis <mitch.curtis@qt.io>2019-01-10 10:45:53 +0000
commit574b56913f3d1ca6ad05617c32bd275807613c6b (patch)
tree3d4706b3a9ad918ae7feb75e0bdf30c9284530e2 /src
parent68511d41d50b1a136fb0e74fdabfd362e0b21a1a (diff)
Doc: mention that some filtered events need to be explicitly accepted
QKeyEvent's detailed description already documents this: "A key event contains a special accept flag that indicates whether the receiver will handle the key event. This flag is set by default for QEvent::KeyPress and QEvent::KeyRelease, so there is no need to call accept() when acting on a key event. For QEvent::ShortcutOverride the receiver needs to explicitly accept the event to trigger the override. Calling ignore() on a key event will propagate it to the parent widget. The event is propagated up the parent widget chain until a widget accepts it or an event filter consumes it." However, someone looking at eventFilter() won't see this, resulting in the shortcut not being consumed and propagating elsewhere, so mention it in the docs for eventFilter() too. Change-Id: I14fece52133be641ccdabd81f75706cd10b64669 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qobject.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 14af9ac8ef..b5d97c5538 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1374,6 +1374,10 @@ void QObject::customEvent(QEvent * /* event */)
might have reimplemented eventFilter() for its own internal
purposes.
+ Some events, such as \l QEvent::ShortcutOverride must be explicitly
+ accepted (by calling \l {QEvent::}{accept()} on them) in order to prevent
+ propagation.
+
\warning If you delete the receiver object in this function, be
sure to return true. Otherwise, Qt will forward the event to the
deleted object and the program might crash.