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

QEventLoop Class Reference

The QEventLoop class manages the event queue. More...

#include <qeventloop.h>

Inherits QObject.

Inherited by QMotif.

List of all member functions.

Public Members

Signals

Protected Members


Detailed Description

The QEventLoop class manages the event queue.

It receives events from the window system and other sources. It then sends them to QApplication for prcoessing and delivery.

QEventLoop allows the application programmer to have more control over event delivery. Programs that perform long operations can call either processOneEvent() or processEvents() with various ProcessEvent values OR'ed together to control which events should be delivered.

QEventLoop also allows the integration of an external event loop with the Qt event loop. The Motif Extension included with Qt includes a reimplementation of QEventLoop for merging Qt and Motif events together.

See also Main Window and Related Classes and Event Classes.


Member Type Documentation

QEventLoop::ProcessEvents

This enum controls the types of events processed by the processOneEvent(), processEvents() and processNextEvent() functions.

See also processOneEvent(), processEvents(), and processNextEvent().


Member Function Documentation

QEventLoop::QEventLoop ( QObject * parent = 0, const char * name = 0 )

Creates a QEventLoop object. The parent and name arguments are passed on to the QObject constructor.

QEventLoop::~QEventLoop ()

Destructs the QEventLoop object.

void QEventLoop::aboutToBlock () [signal]

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

See also awake().

int QEventLoop::activateSocketNotifiers ()

Activates all pending socket notifiers and returns the number of socket notifiers that were activated.

int QEventLoop::activateTimers ()

Activates all Qt timers and returns the number of timers that were activated.

QEventLoop subclasses that do their own timer handling need to call this after the time returned by timeToWait() has elapsed.

void QEventLoop::awake () [signal]

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

See also wakeUp() and aboutToBlock().

int QEventLoop::enterLoop () [virtual]

This function enters the main event loop (recursively). Do not call it unless you really know what you are doing.

int QEventLoop::exec () [virtual]

Enters the main event loop and waits until exit() is called, and returns the value that was set to exit().

It is necessary to call this function to start event handling. The main event loop receives events from the window system and dispatches these to the application widgets.

Generally speaking, no user interaction can take place before calling exec(). As a special case, modal widgets like QMessageBox can be used before calling exec(), because modal widgets call exec() to start a local event loop.

To make your application perform idle processing, i.e. executing a special function whenever there are no pending events, use a QTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents().

See also QApplication::quit(), exit(), and processEvents().

void QEventLoop::exit ( int retcode = 0 ) [virtual]

Tells the event loop to exit with a return code.

After this function has been called, the event loop returns from the call to exec(). The exec() function returns retcode.

By convention, a retcode of 0 means success, and any non-zero value indicates an error.

Note that unlike the C library function of the same name, this function does return to the caller -- it is event processing that stops.

See also QApplication::quit() and exec().

void QEventLoop::exitLoop () [virtual]

This function exits from a recursive call to the main event loop. Do not call it unless you really know what you are doing.

bool QEventLoop::hasPendingEvents () const [virtual]

Returns TRUE if there is an event waiting, otherwise it returns FALSE.

int QEventLoop::loopLevel () const [virtual]

Returns the current loop level.

void QEventLoop::processEvents ( ProcessEventsFlags flags, int maxTime = 3000 ) [virtual]

Process pending events that match flags for a maximum of maxTime milliseconds, or until there are no more events to process, which ever is shorter. If this function is called without any arguments, then all event types are processed for a maximum of 3 seconds (3000 milliseconds).

bool QEventLoop::processNextEvent ( ProcessEventsFlags flags, bool canWait ) [virtual protected]

Processes the next event received that matches flags. If no events matching flags are available, this function will wait for the next event if canWait is TRUE, otherwise it returns immediately.

Returns TRUE if an event was processed, otherwise returns FALSE.

void QEventLoop::processOneEvent ( ProcessEventsFlags flags ) [virtual]

Process one, and exactly one event, that matches flags, waiting for an event if necessary

See also processEvents().

void QEventLoop::registerSocketNotifier ( QSocketNotifier * notifier ) [virtual]

Registers notifier with the event loop. Subclasses need to reimplement this method to tie a socket notifier into another event loop. Reimplementations MUST call the base implementation.

void QEventLoop::setSocketNotifierPending ( QSocketNotifier * notifier )

Marks notifier as pending. The socket notifier will be activated the next time activateSocketNotifiers() is called.

int QEventLoop::timeToWait () const

Returns the number of milliseconds that Qt needs to handle its timers or -1 if there are no timers running.

QEventLoop subclasses that do their own timer handling need to use this to make sure that Qt's timers continue to work. returns

void QEventLoop::unregisterSocketNotifier ( QSocketNotifier * notifier ) [virtual]

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

void QEventLoop::wakeUp () [virtual]

Wakes up the event loop. This function is thread safe, and can be called by any running thread.

See also awake().


This file is part of the Qt toolkit. Copyright © 1995-2002 Trolltech. All Rights Reserved.


Copyright © 2002 TrolltechTrademarks
Qt version 3.1.0-b1