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>
This commit is contained in:
parent
68511d41d5
commit
574b56913f
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user