CopperSpice API  1.7.4
QEventLoop Class Reference

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

Inheritance diagram for QEventLoop:
QObject

Public Typedefs

using ProcessEventsFlags = QFlags< ProcessEventsFlag >
 

Public Types

enum  ProcessEventsFlag
 

Public Slots

void quit ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QEventLoop (QObject *parent=nullptr)
 
 ~QEventLoop ()
 
int exec (ProcessEventsFlags flags=AllEvents)
 
void exit (int returnCode=0)
 
bool isRunning () const
 
void processEvents (ProcessEventsFlags flags, int maxTime)
 
bool processEvents (ProcessEventsFlags flags=AllEvents)
 
void wakeUp ()
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &objName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Additional Inherited Members

- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

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 within the event loop, calling exit() will force exec() to return.

See also
QAbstractEventDispatcher

Member Typedef Documentation

Member Enumeration Documentation

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

ConstantValueDescription
QEventLoop::AllEvents 0x00 All events. Note that DeferredDelete events are processed specially. Refer to QObject::deleteLater() for more details.
QEventLoop::ExcludeUserInputEvents 0x01 Do not process user input events, such as ButtonPress and KeyPress. The events are not discarded, they will be delivered the next time processEvents() is called without the ExcludeUserInputEvents flag.
QEventLoop::ExcludeSocketNotifiers0x02 Do not process socket notifier events. The events are not discarded, they will be delivered the next time processEvents() is called without the ExcludeSocketNotifiers flag.
QEventLoop::WaitForMoreEvents0x04 Wait for events if no pending events are available.
QEventLoop::DeferredDeletion? deprecated value, do not use
See also
processEvents()

Constructor & Destructor Documentation

QEventLoop::QEventLoop ( QObject parent = nullptr)
explicit

Constructs an event loop object with the given parent.

QEventLoop::~QEventLoop ( )

Destroys the event loop object.

Method Documentation

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(). If flags are specified, only events of the types allowed by the flags will be processed.

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 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(), processEvents()
void QEventLoop::exit ( int  returnCode = 0)

Instructs the event loop to exit with a return code. After this method has been called, the event loop returns from the call to exec(). The exec() method returns returnCode. By convention, a returnCode of 0 means success and any non-zero value indicates an error.

Unlike the C library function of the same name, this method returns to the caller, it is the event processing which stops.

See also
QCoreApplication::quit(), quit(), exec()
bool QEventLoop::isRunning ( ) const

Returns true if the event loop is running, otherwise returns false. The event loop is considered running from the time when exec() is called until exit() is called.

See also
exec(), exit()
void QEventLoop::processEvents ( ProcessEventsFlags  flags,
int  maxTime 
)

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 method is useful when there is a long operation and you want to show progress without allowing user input. For this to happen, pass the enum value QEventLoop::ExcludeUserInputEvents in the flags parameter.

  • This method does not process events continuously, it returns after all available events are processed.
  • Specifying the WaitForMoreEvents flag makes will be ignored.
bool QEventLoop::processEvents ( ProcessEventsFlags  flags = AllEvents)

Processes pending events that match flags until there are no more events to process. Returns true if pending events were handled, otherwise returns false.

This method is useful when there is a long operation and you want to show progress without allowing user input. For this to happen, pass the enum value QEventLoop::ExcludeUserInputEvents in the flags parameter.

This method is simply a wrapper for QAbstractEventDispatcher::processEvents(). Refer to the documentation for that method for more details.

void QEventLoop::quit ( )
slot

Instructs the event loop to exit normally. Equivalent to calling exit(0).

See also
QCoreApplication::quit(), exit()
void QEventLoop::wakeUp ( )

Wakes up the event loop.

See also
QAbstractEventDispatcher::wakeUp()