From 574b56913f3d1ca6ad05617c32bd275807613c6b Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 7 Jan 2019 14:55:58 +0100 Subject: 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 Reviewed-by: Venugopal Shivashankar Reviewed-by: Paul Wicking --- src/corelib/kernel/qobject.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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. -- cgit v1.2.3