Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QEventLoopLocker Class Reference

\inmodule QtCore More...

#include <qeventloop.h>

+ Collaboration diagram for QEventLoopLocker:

Public Member Functions

Q_NODISCARD_CTOR Q_CORE_EXPORT QEventLoopLocker () noexcept
 Creates an event locker operating on the QCoreApplication.
 
Q_NODISCARD_CTOR Q_CORE_EXPORT QEventLoopLocker (QEventLoop *loop) noexcept
 Creates an event locker operating on the loop.
 
Q_NODISCARD_CTOR Q_CORE_EXPORT QEventLoopLocker (QThread *thread) noexcept
 Creates an event locker operating on the thread.
 
Q_CORE_EXPORT ~QEventLoopLocker ()
 Destroys this event loop locker object.
 
Q_NODISCARD_CTOR QEventLoopLocker (QEventLoopLocker &&other) noexcept
 
void swap (QEventLoopLocker &other) noexcept
 

Friends

class QEventLoopLockerPrivate
 
void swap (QEventLoopLocker &lhs, QEventLoopLocker &rhs) noexcept
 

Detailed Description

\inmodule QtCore

The QEventLoopLocker class provides a means to quit an event loop when it is no longer needed.

Since
5.0

The QEventLoopLocker operates on particular objects - either a QCoreApplication instance, a QEventLoop instance or a QThread instance.

This makes it possible to, for example, run a batch of jobs with an event loop and exit that event loop after the last job is finished. That is accomplished by keeping a QEventLoopLocker with each job instance.

The variant which operates on QCoreApplication makes it possible to finish asynchronously running jobs after the last gui window has been closed. This can be useful for example for running a job which uploads data to a network.

See also
QEventLoop, QCoreApplication

Definition at line 58 of file qeventloop.h.

Constructor & Destructor Documentation

◆ QEventLoopLocker() [1/4]

QEventLoopLocker::QEventLoopLocker ( )
noexcept

Creates an event locker operating on the QCoreApplication.

The application will attempt to quit when there are no more QEventLoopLockers operating on it, as long as QCoreApplication::isQuitLockEnabled() is true.

Note that attempting a quit may not necessarily result in the application quitting, if there for example are open windows, or the QEvent::Quit event is ignored.

See also
QCoreApplication::quit(), QCoreApplication::isQuitLockEnabled()

Definition at line 357 of file qeventloop.cpp.

References QCoreApplication::instance().

+ Here is the call graph for this function:

◆ QEventLoopLocker() [2/4]

QEventLoopLocker::QEventLoopLocker ( QEventLoop * loop)
explicitnoexcept

Creates an event locker operating on the loop.

This particular QEventLoop will quit when there are no more QEventLoopLockers operating on it.

See also
QEventLoop::quit()

Definition at line 370 of file qeventloop.cpp.

◆ QEventLoopLocker() [3/4]

QEventLoopLocker::QEventLoopLocker ( QThread * thread)
explicitnoexcept

Creates an event locker operating on the thread.

This particular QThread will quit when there are no more QEventLoopLockers operating on it.

See also
QThread::quit()

Definition at line 383 of file qeventloop.cpp.

◆ ~QEventLoopLocker()

QEventLoopLocker::~QEventLoopLocker ( )

Destroys this event loop locker object.

Definition at line 428 of file qeventloop.cpp.

◆ QEventLoopLocker() [4/4]

QEventLoopLocker::QEventLoopLocker ( QEventLoopLocker && other)
inlinenoexcept
Since
6.7

Move-constructs an event-loop locker from other. other will have a no-op destructor, while responsibility for preventing the QEventLoop/QThread/QCoreApplication from quitting is transferred to the new object.

Definition at line 66 of file qeventloop.h.

References other().

+ Here is the call graph for this function:

Member Function Documentation

◆ swap()

QEventLoopLocker::swap ( QEventLoopLocker & other)
inlinenoexcept
Since
6.7

Swaps the object and the state of this QEventLoopLocker with other. This operation is very fast and never fails.

Definition at line 70 of file qeventloop.h.

References other().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ QEventLoopLockerPrivate

friend class QEventLoopLockerPrivate
friend

Definition at line 75 of file qeventloop.h.

◆ swap

QEventLoopLocker::swap ( QEventLoopLocker & lhs,
QEventLoopLocker & rhs )
friend
Since
6.7

Swaps the object and the state of lhs with rhs. This operation is very fast and never fails.

Definition at line 71 of file qeventloop.h.


The documentation for this class was generated from the following files: