Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qeventloop.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QEVENTLOOP_H
6#define QEVENTLOOP_H
7
8#include <QtCore/qobject.h>
9#include <QtCore/qdeadlinetimer.h>
10
12
14class QEventLoopPrivate;
15
16class Q_CORE_EXPORT QEventLoop : public QObject
17{
18 Q_OBJECT
19 Q_DECLARE_PRIVATE(QEventLoop)
20 friend class QEventLoopLocker;
21
22public:
23 explicit QEventLoop(QObject *parent = nullptr);
24 ~QEventLoop();
25
26 enum ProcessEventsFlag {
27 AllEvents = 0x00,
28 ExcludeUserInputEvents = 0x01,
29 ExcludeSocketNotifiers = 0x02,
30 WaitForMoreEvents = 0x04,
31 X11ExcludeTimers = 0x08,
32 EventLoopExec = 0x20,
33 DialogExec = 0x40,
34 ApplicationExec = 0x80,
35 };
36 Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)
37 Q_FLAG(ProcessEventsFlags)
38
39 bool processEvents(ProcessEventsFlags flags = AllEvents);
40 void processEvents(ProcessEventsFlags flags, int maximumTime);
41 void processEvents(ProcessEventsFlags flags, QDeadlineTimer deadline);
42
43 int exec(ProcessEventsFlags flags = AllEvents);
44 bool isRunning() const;
45
46 void wakeUp();
47
48 bool event(QEvent *event) override;
49
50public Q_SLOTS:
51 void exit(int returnCode = 0);
52 void quit();
53};
54
55Q_DECLARE_OPERATORS_FOR_FLAGS(QEventLoop::ProcessEventsFlags)
56
57class QEventLoopLockerPrivate;
58
60{
61public:
62 Q_NODISCARD_CTOR Q_CORE_EXPORT QEventLoopLocker() noexcept;
66
70
71 void swap(QEventLoopLocker &other) noexcept { std::swap(p, other.p); }
72 friend void swap(QEventLoopLocker &lhs, QEventLoopLocker &rhs) noexcept { lhs.swap(rhs); }
73
74private:
77
78 //
79 // Private implementation details.
80 // Do not call from public inline API!
81 //
82 enum class Type : quintptr {
83 EventLoop,
84 Thread,
85 Application,
86 };
87 explicit QEventLoopLocker(void *ptr, Type t) noexcept;
88 quintptr p;
89 static constexpr quintptr TypeMask = 0x3;
90 Type type() const { return Type(p & TypeMask); }
91 void *pointer() const { return reinterpret_cast<void *>(p & ~TypeMask); }
92 template <typename Func>
93 void visit(Func func) const;
94};
95
96QT_END_NAMESPACE
97
98#endif // QEVENTLOOP_H
\inmodule QtCore
Definition qcoreevent.h:391
\inmodule QtCore
int scopeLevel() const
int loopLevel() const
QDeferredDeleteEvent(int loopLevel, int scopeLevel)
Constructs a deferred delete event with the given loop and scope level.
\inmodule QtCore
Definition qeventloop.h:60
Q_CORE_EXPORT ~QEventLoopLocker()
Destroys this event loop locker object.
\inmodule QtCore
Definition qeventloop.h:17
\inmodule QtCore
Definition qcoreevent.h:50
\inmodule QtCore
Definition qcoreevent.h:373
Combined button and popup list for selecting options.
#define __has_include(x)
QString qAppName()
Q_TRACE_POINT(qtcore, QCoreApplication_notify_exit, bool consumed, bool filtered)
void QT_MANGLE_NAMESPACE qt_startup_hook()
static QString qAppFileName()
QList< QtStartUpFunction > QStartUpFuncList
Q_TRACE_METADATA(qtcore, "ENUM { AUTO, RANGE User ... MaxUser } QEvent::Type;")
QString qtTrId(const char *id, int n)
Q_TRACE_POINT(qtcore, QCoreApplication_postEvent_exit)
static void qt_call_pre_routines()
qsizetype qGlobalPostedEventsCount()
static Q_CONSTINIT bool preRoutinesCalled
QList< QtCleanUpFunction > QVFuncList
static void replacePercentN(QString *result, int n)
Q_TRACE_POINT(qtcore, QCoreApplication_postEvent_event_compressed, QObject *receiver, QEvent *event)
Q_TRACE_POINT(qtcore, QCoreApplication_postEvent_entry, QObject *receiver, QEvent *event, QEvent::Type type)
Q_TRACE_PREFIX(qtcore, "#include <qcoreevent.h>")
Q_CORE_EXPORT void qAddPostRoutine(QtCleanUpFunction)
void(* QtCleanUpFunction)()
void(* QtStartUpFunction)()
Q_CORE_EXPORT void qAddPreRoutine(QtStartUpFunction)
Q_CORE_EXPORT void qRemovePostRoutine(QtCleanUpFunction)
#define qApp
#define Q_EVENT_DISABLE_COPY(Class)
Definition qcoreevent.h:17
#define Q_DECL_EVENT_COMMON(Class)
Definition qcoreevent.h:24
Q_GLOBAL_STATIC(QReadWriteLock, g_updateMutex)