![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qabstractnativeeventfilter.h>
Public Member Functions | |
QAbstractNativeEventFilter () | |
Creates a native event filter. | |
virtual | ~QAbstractNativeEventFilter () |
Destroys the native event filter. | |
virtual bool | nativeEventFilter (const QByteArray &eventType, void *message, qintptr *result)=0 |
This method is called for every native event. | |
\inmodule QtCore
The QAbstractNativeEventFilter class provides an interface for receiving native events, such as MSG or XCB event structs.
Definition at line 13 of file qabstractnativeeventfilter.h.
QAbstractNativeEventFilter::QAbstractNativeEventFilter | ( | ) |
Creates a native event filter.
By default this doesn't do anything. Remember to install it on the application object.
Definition at line 24 of file qabstractnativeeventfilter.cpp.
|
virtual |
Destroys the native event filter.
This automatically removes it from the application.
Definition at line 34 of file qabstractnativeeventfilter.cpp.
|
pure virtual |
This method is called for every native event.
It is called by the QPA platform plugin. On Windows, it is called by the event dispatcher.
The type of event eventType is specific to the platform plugin chosen at run-time, and can be used to cast message to the right type.
On X11, eventType is set to "xcb_generic_event_t", and the message can be casted to a xcb_generic_event_t pointer.
On Windows, eventType is set to "windows_generic_MSG" for messages sent to toplevel windows, and "windows_dispatcher_MSG" for system-wide messages such as messages from a registered hot key. In both cases, the message can be casted to a MSG pointer. The result pointer is only used on Windows, and corresponds to the LRESULT pointer.
On macOS, eventType is set to "mac_generic_NSEvent", and the message can be casted to an NSEvent pointer.
In your reimplementation of this function, if you want to filter the message out, i.e. stop it being handled further, return true; otherwise return false.
{Linux example}
{Windows example}
{macOS example}
mycocoaeventfilter.h:
mycocoaeventfilter.mm:
myapp.pro:
Implemented in MyCocoaEventFilter, MyMSGEventFilter, MyMSGEventFilter, MyXcbEventFilter, MyXcbEventFilter, QBenchmarkEvent, QQnxWindowGrabber, QWindowsRemovableDriveListener, and QWindowsRemovableDriveListener.