|  | Home · All Classes · Modules

# QAbstractEventDispatcher Class Reference
[QtCore module]

The QAbstractEventDispatcher class provides an interface to manage Qt's event queue. More...

Inherits QObject.

### Methods

- __init__ (self, QObject parent = None)
- closingDown (self)
- flush (self)
- bool hasPendingEvents (self)
- interrupt (self)
- bool processEvents (self, QEventLoop.ProcessEventsFlags)
- list-of-tuple-of-int-int registeredTimers (self, QObject)
- registerSocketNotifier (self, QSocketNotifier)
- int registerTimer (self, int, QObject)
- registerTimer (self, int, int, QObject)
- startingUp (self)
- unregisterSocketNotifier (self, QSocketNotifier)
- bool unregisterTimer (self, int)
- bool unregisterTimers (self, QObject)
- wakeUp (self)

### Static Methods

- QAbstractEventDispatcher instance (QThread thread = None)

### Qt Signals

- void aboutToBlock ()
- void awake ()

## Detailed Description

The QAbstractEventDispatcher class provides an interface to manage Qt's event queue.

An event dispatcher receives events from the window system and other sources. It then sends them to the QCoreApplication or QApplication instance for processing and delivery. QAbstractEventDispatcher provides fine-grained control over event delivery.

For simple control of event processing use QCoreApplication.processEvents().

For finer control of the application's event loop, call instance() and call functions on the QAbstractEventDispatcher object that is returned. If you want to use your own instance of QAbstractEventDispatcher or of a QAbstractEventDispatcher subclass, you must create your instance before you create the QApplication object.

The main event loop is started by calling QCoreApplication.exec(), and stopped by calling QCoreApplication.exit(). Local event loops can be created using QEventLoop.

Programs that perform long operations can call processEvents() with a bitwise OR combination of various QEventLoop.ProcessEventsFlag values to control which events should be delivered.

QAbstractEventDispatcher also allows the integration of an external event loop with the Qt event loop. For example, the Motif Extension Qt Solution includes a reimplementation of QAbstractEventDispatcher that merges Qt and Motif events together.

See also QEventLoop and QCoreApplication.

## Method Documentation

### QAbstractEventDispatcher.__init__ (self, QObject parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new event dispatcher with the given parent.

### QAbstractEventDispatcher.closingDown (self)

### QAbstractEventDispatcher.flush (self)

This method is abstract and should be reimplemented in any sub-class.

Flushes the event queue. This normally returns almost immediately. Does nothing on platforms other than X11.

### bool QAbstractEventDispatcher.hasPendingEvents (self)

This method is abstract and should be reimplemented in any sub-class.

Returns true if there is an event waiting; otherwise returns false.

### QAbstractEventDispatcher QAbstractEventDispatcher.instance (QThread thread = None)

Returns a pointer to the event dispatcher object for the specified thread. If thread is zero, the current thread is used. If no event dispatcher exists for the specified thread, this function returns 0.

Note: If Qt is built without thread support, the thread argument is ignored.

### QAbstractEventDispatcher.interrupt (self)

This method is abstract and should be reimplemented in any sub-class.

Interrupts event dispatching; i.e. the event dispatcher will return from processEvents() as soon as possible.

### bool QAbstractEventDispatcher.processEvents (self, QEventLoop.ProcessEventsFlags)

This method is abstract and should be reimplemented in any sub-class.

Processes pending events that match flags until there are no more events to process. Returns true if an event was processed; otherwise returns false.

This function is especially useful if you have a long running operation and want to show its progress without allowing user input; i.e. by using the QEventLoop.ExcludeUserInputEvents flag.

If the QEventLoop.WaitForMoreEvents flag is set in flags, 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 QEventLoop.WaitForMoreEvents flag is not set in flags, 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 hasPendingEvents().

### list-of-tuple-of-int-int QAbstractEventDispatcher.registeredTimers (self, QObject)

This method is abstract and should be reimplemented in any sub-class.

Returns a list of registered timers for object. The timer ID is the first member in each pair; the interval is the second.

### QAbstractEventDispatcher.registerSocketNotifier (self, QSocketNotifier)

This method is abstract and should be reimplemented in any sub-class.

Registers notifier with the event loop. Subclasses must implement this method to tie a socket notifier into another event loop.

### int QAbstractEventDispatcher.registerTimer (self, int, QObject)

Registers a timer with the specified interval for the given object.

### QAbstractEventDispatcher.registerTimer (self, int, int, QObject)

This method is abstract and should be reimplemented in any sub-class.

Register a timer with the specified timerId and interval for the given object.

### QAbstractEventDispatcher.startingUp (self)

### QAbstractEventDispatcher.unregisterSocketNotifier (self, QSocketNotifier)

This method is abstract and should be reimplemented in any sub-class.

Unregisters notifier from the event dispatcher. Subclasses must reimplement this method to tie a socket notifier into another event loop. Reimplementations must call the base implementation.

### bool QAbstractEventDispatcher.unregisterTimer (self, int)

This method is abstract and should be reimplemented in any sub-class.

Unregisters the timer with the given timerId. Returns true if successful; otherwise returns false.

See also registerTimer() and unregisterTimers().

### bool QAbstractEventDispatcher.unregisterTimers (self, QObject)

This method is abstract and should be reimplemented in any sub-class.

Unregisters all the timers associated with the given object. Returns true if all timers were successful removed; otherwise returns false.

See also unregisterTimer() and registeredTimers().

### QAbstractEventDispatcher.wakeUp (self)

This method is abstract and should be reimplemented in any sub-class.

Wakes up the event loop.

Note: This function is thread-safe.

See also awake().

## Qt Signal Documentation

### void aboutToBlock ()

This is the default overload of this signal.

This signal is emitted before the event loop calls a function that could block.

See also awake().

### void awake ()

This is the default overload of this signal.

This signal is emitted after the event loop returns from a function that could block.

See also wakeUp() and aboutToBlock().