QAbstractEventDispatcher¶
The
QAbstractEventDispatcherclass provides an interface to manage Qt’s event queue. More…

Synopsis¶
Functions¶
def
filterNativeEvent(eventType, message, result)def
installNativeEventFilter(filterObj)def
registerTimer(interval, timerType, object)def
removeNativeEventFilter(filterObj)
Virtual functions¶
def
closingDown()def
flush()def
hasPendingEvents()def
interrupt()def
processEvents(flags)def
registerSocketNotifier(notifier)def
registerTimer(timerId, interval, timerType, object)def
registeredTimers(object)def
remainingTime(timerId)def
startingUp()def
unregisterSocketNotifier(notifier)def
unregisterTimer(timerId)def
unregisterTimers(object)def
wakeUp()
Signals¶
def
aboutToBlock()def
awake()
Static functions¶
def
instance([thread=None])
Detailed Description¶
An event dispatcher receives events from the window system and other sources. It then sends them to the
QCoreApplicationorQApplicationinstance for processing and delivery.QAbstractEventDispatcherprovides fine-grained control over event delivery.For simple control of event processing use
processEvents().For finer control of the application’s event loop, call
instance()and call functions on theQAbstractEventDispatcherobject that is returned. If you want to use your own instance ofQAbstractEventDispatcheror of aQAbstractEventDispatchersubclass, you must install it withsetEventDispatcher()orsetEventDispatcher()before a default event dispatcher has been installed.The main event loop is started by calling
exec(), and stopped by callingexit(). Local event loops can be created usingQEventLoop.Programs that perform long operations can call
processEvents()with a bitwise OR combination of variousProcessEventsFlagvalues to control which events should be delivered.
QAbstractEventDispatcheralso allows the integration of an external event loop with the Qt event loop.See also
- class PySide2.QtCore.QAbstractEventDispatcher([parent=None])¶
- param parent:
Constructs a new event dispatcher with the given
parent.
- PySide2.QtCore.QAbstractEventDispatcher.aboutToBlock()¶
- PySide2.QtCore.QAbstractEventDispatcher.awake()¶
- PySide2.QtCore.QAbstractEventDispatcher.closingDown()¶
- PySide2.QtCore.QAbstractEventDispatcher.filterNativeEvent(eventType, message, result)¶
- Parameters:
eventType –
PySide2.QtCore.QByteArraymessage –
voidresult –
long
- Return type:
bool
Sends
messagethrough the event filters that were set byinstallNativeEventFilter(). This function returnstrueas soon as an event filter returnstrue, and false otherwise to indicate that the processing of the event should continue.Subclasses of
QAbstractEventDispatchermust call this function for all messages received from the system to ensure compatibility with any extensions that may be used in the application. The type of eventeventTypeis specific to the platform plugin chosen at run-time, and can be used to cast message to the right type. Theresultpointer is only used on Windows, and corresponds to the LRESULT pointer.Note that the type of
messageis platform dependent. SeeQAbstractNativeEventFilterfor details.
- PySide2.QtCore.QAbstractEventDispatcher.flush()¶
Depending from the event dispatcher implementation does nothing or calls
sendPostedEvents().
- PySide2.QtCore.QAbstractEventDispatcher.hasPendingEvents()¶
- Return type:
bool
Returns
trueif there is an event waiting; otherwise returns false. This function is an implementation detail forhasPendingEvents()and must not be called directly.
- PySide2.QtCore.QAbstractEventDispatcher.installNativeEventFilter(filterObj)¶
- Parameters:
filterObj –
PySide2.QtCore.QAbstractNativeEventFilter
Installs an event filter
filterObjfor all native events received by the application.The event filter
filterObjreceives events via itsnativeEventFilter()function, which is called for all events received by all threads.The
nativeEventFilter()function should return true if the event should be filtered, (in this case, stopped). It should return false to allow normal Qt processing to continue: the native event can then be translated into aQEventand handled by the standard Qteventfiltering, e.g.installEventFilter().If multiple event filters are installed, the filter that was installed last is activated first.
Note
The filter function set here receives native messages, that is, MSG or XEvent structs.
For maximum portability, you should always try to use
QEventobjects andinstallEventFilter()whenever possible.See also
- static PySide2.QtCore.QAbstractEventDispatcher.instance([thread=None])¶
- Parameters:
thread –
PySide2.QtCore.QThread- Return type:
Returns a pointer to the event dispatcher object for the specified
thread. IfthreadisNone, the current thread is used. If no event dispatcher exists for the specified thread, this function returnsNone.Note
If Qt is built without thread support, the
threadargument is ignored.
- PySide2.QtCore.QAbstractEventDispatcher.interrupt()¶
Interrupts event dispatching. The event dispatcher will return from
processEvents()as soon as possible.
- PySide2.QtCore.QAbstractEventDispatcher.processEvents(flags)¶
- Parameters:
flags –
ProcessEventsFlags- Return type:
bool
Processes pending events that match
flagsuntil there are no more events to process. Returnstrueif an event was processed; otherwise returnsfalse.This function is especially useful if you have a long running operation, and want to show its progress without allowing user input by using the
ExcludeUserInputEventsflag.If the
WaitForMoreEventsflag is set inflags, the behavior of this function is as follows:If events are available, this function returns after processing them.
If no events are available, this function will wait until more are available and return after processing newly available events.
If the
WaitForMoreEventsflag is not set inflags, and no events are available, this function will return immediately.Note
This function does not process events continuously; it returns after all available events are processed.
See also
- PySide2.QtCore.QAbstractEventDispatcher.registerSocketNotifier(notifier)¶
- Parameters:
notifier –
PySide2.QtCore.QSocketNotifier
Registers
notifierwith the event loop. Subclasses must implement this method to tie a socket notifier into another event loop.
- PySide2.QtCore.QAbstractEventDispatcher.registerTimer(interval, timerType, object)¶
- Parameters:
interval – int
timerType –
TimerTypeobject –
PySide2.QtCore.QObject
- Return type:
int
Registers a timer with the specified
intervalandtimerTypefor the givenobjectand returns the timer id.
- PySide2.QtCore.QAbstractEventDispatcher.registerTimer(timerId, interval, timerType, object)
- Parameters:
timerId – int
interval – int
timerType –
TimerTypeobject –
PySide2.QtCore.QObject
Register a timer with the specified
timerId,interval, andtimerTypefor the givenobject.
- PySide2.QtCore.QAbstractEventDispatcher.registeredTimers(object)¶
- Parameters:
object –
PySide2.QtCore.QObject- Return type:
Returns a list of registered timers for
object. TheTimerInfostruct hastimerId,interval, andtimerTypemembers.See also
TimerType
- PySide2.QtCore.QAbstractEventDispatcher.remainingTime(timerId)¶
- Parameters:
timerId – int
- Return type:
int
Returns the remaining time in milliseconds with the given
timerId. If the timer is inactive, the returned value will be -1. If the timer is overdue, the returned value will be 0.See also
TimerType
- PySide2.QtCore.QAbstractEventDispatcher.removeNativeEventFilter(filterObj)¶
- Parameters:
filterObj –
PySide2.QtCore.QAbstractNativeEventFilter
Removes the event filter
filterfrom this object. The request is ignored if such an event filter has not been installed.All event filters for this object are automatically removed when this object is destroyed.
It is always safe to remove an event filter, even during event filter filter activation (that is, even from within the
nativeEventFilter()function).
- PySide2.QtCore.QAbstractEventDispatcher.startingUp()¶
- PySide2.QtCore.QAbstractEventDispatcher.unregisterSocketNotifier(notifier)¶
- Parameters:
notifier –
PySide2.QtCore.QSocketNotifier
Unregisters
notifierfrom the event dispatcher. Subclasses must reimplement this method to tie a socket notifier into another event loop. Reimplementations must call the base implementation.
- PySide2.QtCore.QAbstractEventDispatcher.unregisterTimer(timerId)¶
- Parameters:
timerId – int
- Return type:
bool
Unregisters the timer with the given
timerId. Returnstrueif successful; otherwise returnsfalse.See also
- PySide2.QtCore.QAbstractEventDispatcher.unregisterTimers(object)¶
- Parameters:
object –
PySide2.QtCore.QObject- Return type:
bool
Unregisters all the timers associated with the given
object. Returnstrueif all timers were successful removed; otherwise returnsfalse.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.