Home · All Classes · Main Classes · Annotated · Grouped Classes · Functions

QEventLoop Class Reference

The QEventLoop class provides a means of entering and leaving an event loop. More...

#include <QEventLoop>

Part of the QtCore module.

Inherits QObject.

Public Types

Public Functions

Public Slots

Additional Inherited Members


Detailed Description

The QEventLoop class provides a means of entering and leaving an event loop.

At any time, you can create a QEventLoop object and call exec() on it to start a local event loop. From withing the event loop, calling exit() will force exec() to return.

See also QAbstractEventDispatcher.


Member Type Documentation

enum QEventLoop::ProcessEventsFlag
flags QEventLoop::ProcessEventsFlags

This enum controls the types of events processed by the processEvents() functions.

ConstantValueDescription
QEventLoop::AllEvents0x00- All events are processed
QEventLoop::ExcludeUserInputExcludeUserInputEvents- Do not process user input events, such as ButtonPress and KeyPress.
QEventLoop::ExcludeSocketNotifiers0x02- Do not process socket notifier events.
QEventLoop::WaitForMoreWaitForMoreEvents- Wait for events if no pending events are available.

The ProcessEventsFlags type stores an OR combination of ProcessEventsFlag values.

See also processEvents().


Member Function Documentation

QEventLoop::QEventLoop ( QObject * parent = 0 )

QEventLoop::~QEventLoop ()

int QEventLoop::exec ( ProcessEventsFlags flags = AllEvents )

Enters the main event loop and waits until exit() is called. Returns the value that was passed 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 use their own 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 sophisticated idle processing schemes can be achieved using processEvents().

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

void QEventLoop::exit ( int returnCode = 0 )

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 returnCode.

By convention, a returnCode 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().

bool QEventLoop::processEvents ( ProcessEventsFlags flags = AllEvents )

void QEventLoop::processEvents ( ProcessEventsFlags flags, int maxTime )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Process pending events that match flags for a maximum of maxTime milliseconds, or until there are no more events to process, whichever is shorter.

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 ExcludeUserInput flag.

Note: This function does not process events continuously; it returns after all available events are processed.

Note: Specifying the WaitForMoreEvents flag makes no sense and will be ignored.

void QEventLoop::quit ()   [slot]

void QEventLoop::wakeUp ()


Copyright © 2005 Trolltech Trademarks
Qt 4.0.0-rc1