The Qt documentation for Events and Filters states:
You can also filter all events for the entire application by setting an event filter in a QApplication or QCoreApplication object. Such global event filters are invoked before object-specific filters. This is very powerful, but also slows down the delivery of events for each individual event throughout the application.
Therefore, you can create an event filter in QApplication or QCoreApplication and control all events by checking their type .
As an alternative, QCoreApplication uses the virtual notify function to deliver events to objects. Overriding QCoreApplication will allow you to see both the event and the QObject with which the event will initially be sent.
* Note that events are propagated to parent objects if the receiving object ignores the event.
If you decide to use notify , be aware of the future direction for this function:
Direction to the future: this function will not be called for objects that live outside the main thread in Qt 6. Applications that need this function must find other solutions for their event verification needs. This change can be expanded to the main thread, as a result of which this function will become obsolete.
source share