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
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
4#ifndef QEVENTLOOP_H
5#define QEVENTLOOP_H
6
7#include <QtCore/qobject.h>
8#include <QtCore/qdeadlinetimer.h>
9
11
14
15class Q_CORE_EXPORT QEventLoop : public QObject
16{
18 Q_DECLARE_PRIVATE(QEventLoop)
19 friend class QEventLoopLocker;
20
21public:
22 explicit QEventLoop(QObject *parent = nullptr);
23 ~QEventLoop();
24
26 AllEvents = 0x00,
27 ExcludeUserInputEvents = 0x01,
28 ExcludeSocketNotifiers = 0x02,
29 WaitForMoreEvents = 0x04,
30 X11ExcludeTimers = 0x08,
31 EventLoopExec = 0x20,
32 DialogExec = 0x40,
33 ApplicationExec = 0x80,
34 };
35 Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)
36 Q_FLAG(ProcessEventsFlags)
37
38 bool processEvents(ProcessEventsFlags flags = AllEvents);
39 void processEvents(ProcessEventsFlags flags, int maximumTime);
40 void processEvents(ProcessEventsFlags flags, QDeadlineTimer deadline);
41
42 int exec(ProcessEventsFlags flags = AllEvents);
43 bool isRunning() const;
44
45 void wakeUp();
46
47 bool event(QEvent *event) override;
48
49public Q_SLOTS:
50 void exit(int returnCode = 0);
51 void quit();
52};
53
54Q_DECLARE_OPERATORS_FOR_FLAGS(QEventLoop::ProcessEventsFlags)
55
56class QEventLoopLockerPrivate;
57
59{
60public:
61 Q_NODISCARD_CTOR Q_CORE_EXPORT QEventLoopLocker() noexcept;
62 Q_NODISCARD_CTOR Q_CORE_EXPORT explicit QEventLoopLocker(QEventLoop *loop) noexcept;
63 Q_NODISCARD_CTOR Q_CORE_EXPORT explicit QEventLoopLocker(QThread *thread) noexcept;
64 Q_CORE_EXPORT ~QEventLoopLocker();
65
67 : p{std::exchange(other.p, 0)} {}
68 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QEventLoopLocker)
69
70 void swap(QEventLoopLocker &other) noexcept { std::swap(p, other.p); }
71 friend void swap(QEventLoopLocker &lhs, QEventLoopLocker &rhs) noexcept { lhs.swap(rhs); }
72
73private:
74 Q_DISABLE_COPY(QEventLoopLocker)
76
77 //
78 // Private implementation details.
79 // Do not call from public inline API!
80 //
81 enum class Type : quintptr {
82 EventLoop,
83 Thread,
84 Application,
85 };
86 explicit QEventLoopLocker(void *ptr, Type t) noexcept;
87 quintptr p;
88 static constexpr quintptr TypeMask = 0x3;
89 Type type() const { return Type(p & TypeMask); }
90 void *pointer() const { return reinterpret_cast<void *>(p & ~TypeMask); }
91 template <typename Func>
92 void visit(Func func) const;
93};
94
96
97#endif // QEVENTLOOP_H
\inmodule QtCore
\inmodule QtCore
Definition qeventloop.h:59
Q_NODISCARD_CTOR QEventLoopLocker(QEventLoopLocker &&other) noexcept
Definition qeventloop.h:66
friend void swap(QEventLoopLocker &lhs, QEventLoopLocker &rhs) noexcept
Definition qeventloop.h:71
Q_NODISCARD_CTOR Q_CORE_EXPORT QEventLoopLocker() noexcept
Creates an event locker operating on the QCoreApplication.
Q_CORE_EXPORT ~QEventLoopLocker()
Destroys this event loop locker object.
friend class QEventLoopLockerPrivate
Definition qeventloop.h:75
\inmodule QtCore
Definition qeventloop.h:16
ProcessEventsFlag
This enum controls the types of events processed by the processEvents() functions.
Definition qeventloop.h:25
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtCore
Definition qobject.h:103
Combined button and popup list for selecting options.
#define Q_NODISCARD_CTOR
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
static ControlElement< T > * ptr(QWidget *widget)
GLenum type
GLbitfield flags
struct _cl_event * event
GLenum func
Definition qopenglext.h:663
GLdouble GLdouble t
Definition qopenglext.h:243
GLsizei const void * pointer
Definition qopenglext.h:384
GLfloat GLfloat p
[1]
static bool isRunning()
Definition main.cpp:452
#define Q_OBJECT
#define Q_FLAG(x)
#define Q_SLOTS
size_t quintptr
Definition qtypes.h:167
#define explicit
QDeadlineTimer deadline(30s)
QSharedPointer< T > other(t)
[5]
dialog exec()
Definition moc.h:23