Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QAbstractEventDispatcher Class Reference

The QAbstractEventDispatcher class manages Qt's event queue, excluding GUI-related events. More...

    #include <QAbstractEventDispatcher>

Inherits QObject.

- List of all members, including inherited members

### Public Types

- typedef EventFilter

### Writable Properties

- 1 writable property inherited from QObject

### Public Functions

- QAbstractEventDispatcher ( QObject * parent = 0 )
- ~QAbstractEventDispatcher ()
- bool filterEvent ( void * message )
- virtual void flush () = 0
- virtual bool hasPendingEvents () = 0
- virtual void interrupt () = 0
- virtual bool processEvents ( QEventLoop::ProcessEventsFlags flags ) = 0
- virtual void registerSocketNotifier ( QSocketNotifier * notifier ) = 0
- virtual int registerTimer ( int interval, QObject * object ) = 0
- EventFilter setEventFilter ( EventFilter filter )
- virtual void unregisterSocketNotifier ( QSocketNotifier * notifier ) = 0
- virtual bool unregisterTimer ( int timerId ) = 0
- virtual bool unregisterTimers ( QObject * object ) = 0
- virtual void wakeUp () = 0

- 26 public functions inherited from QObject

### Public Slots

- 1 public slot inherited from QObject

### Signals

- void aboutToBlock ()
- void awake ()

- 1 signal inherited from QObject

### Static Public Members

- QAbstractEventDispatcher * instance ( QThread * thread = 0 )

- 4 static public members inherited from QObject

### Protected Functions

- QAbstractEventDispatcher ( QAbstractEventDispatcherPrivate & , QObject * parent )

- 7 protected functions inherited from QObject

## Detailed Description

The QAbstractEventDispatcher class manages Qt's event queue, excluding GUI-related events.

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

For simple control of event processing use QApplication::processEvents().

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

The event loop is started by calling exec(), and stopped by calling exit().

Programs that perform long operations can call processEvents() with various `ProcessEvents` values OR'ed together 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 included with Qt includes a reimplementation of QAbstractEventDispatcher that merges Qt and Motif events together.

See also QEventLoop.

## Member Type Documentation

### typedef QAbstractEventDispatcher::EventFilter

## Member Function Documentation

### QAbstractEventDispatcher::QAbstractEventDispatcher ( QObject * parent = 0 )

### QAbstractEventDispatcher::QAbstractEventDispatcher ( QAbstractEventDispatcherPrivate & , QObject * parent ) `[protected]`

### QAbstractEventDispatcher::~QAbstractEventDispatcher ()

### void QAbstractEventDispatcher::aboutToBlock () `[signal]`

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

See also awake().

### void QAbstractEventDispatcher::awake () `[signal]`

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

See also wakeUp() and aboutToBlock().

### bool QAbstractEventDispatcher::filterEvent ( void * message )

Sends message through the event filter that was set by setEventFilter(). If no event filter has been set, this function returns false; otherwise, this function returns the result of the event filter function.

Subclasses of QAbstractEventDispatcher must call this function for all messages received from the system to ensure compatibility with any extensions that may be used in the application.

See also setEventFilter().

### void QAbstractEventDispatcher::flush () `[pure virtual]`

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

### bool QAbstractEventDispatcher::hasPendingEvents () `[pure virtual]`

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

### QAbstractEventDispatcher * QAbstractEventDispatcher::instance ( QThread * thread = 0 ) `[static]`

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.

### void QAbstractEventDispatcher::interrupt () `[pure virtual]`

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

### bool QAbstractEventDispatcher::processEvents ( QEventLoop::ProcessEventsFlags flags ) `[pure virtual]`

Processes pending events that match flags until there are no more events to process.

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 `ExcludeUserInputEvents` flag.

If the `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 `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.

This function returns true if an event was processed; otherwise it returns false.

See also ProcessEventsFlags and hasPendingEvents().

### void QAbstractEventDispatcher::registerSocketNotifier ( QSocketNotifier * notifier ) `[pure virtual]`

Registers notifier with the event loop. Subclasses must reimplement this method to tie a socket notifier into another event loop. Reimplementations <b>must</b> call the base implementation.

### int QAbstractEventDispatcher::registerTimer ( int interval, QObject * object ) `[pure virtual]`

### EventFilter QAbstractEventDispatcher::setEventFilter ( EventFilter filter )

Sets the event filter filter. Returns a pointer to the filter function previously defined.

The event filter is a function that receives all messages taken from the system event loop before the event is dispatched to the respective target. This includes messages that are not sent to Qt objects.

The function can return true to stop the event to be processed by Qt, or false to continue with the standard event processing.

Only one filter can be defined, but the filter can use the return value to call the previously set event filter. By default, no filter is set (ie. the function returns 0).

### void QAbstractEventDispatcher::unregisterSocketNotifier ( QSocketNotifier * notifier ) `[pure virtual]`

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

### bool QAbstractEventDispatcher::unregisterTimer ( int timerId ) `[pure virtual]`

### bool QAbstractEventDispatcher::unregisterTimers ( QObject * object ) `[pure virtual]`

### void QAbstractEventDispatcher::wakeUp () `[pure virtual]`

Wakes up the event loop.

Note: function is thread-safe.

See also awake().