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
qbasictimer.h
Go to the documentation of this file.
1// Copyright (C) 2020 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 QBASICTIMER_H
5#define QBASICTIMER_H
6
7#include <QtCore/qglobal.h>
8#include <QtCore/qnamespace.h>
9
10#include <chrono>
11
13
14
15class QObject;
16
17class Q_CORE_EXPORT QBasicTimer
18{
19 int id;
20 Q_DISABLE_COPY(QBasicTimer)
21
22public:
23 constexpr QBasicTimer() noexcept : id{0} {}
24 inline ~QBasicTimer() { if (id) stop(); }
25
27 : id{std::exchange(other.id, 0)}
28 {}
29
30 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QBasicTimer)
31
32 void swap(QBasicTimer &other) noexcept { std::swap(id, other.id); }
33
34 bool isActive() const noexcept { return id != 0; }
35 int timerId() const noexcept { return id; }
36 QT_CORE_INLINE_SINCE(6, 5)
37 void start(int msec, QObject *obj);
38 QT_CORE_INLINE_SINCE(6, 5)
39 void start(int msec, Qt::TimerType timerType, QObject *obj);
40 void start(std::chrono::milliseconds duration, QObject *obj);
41 void start(std::chrono::milliseconds duration, Qt::TimerType timerType, QObject *obj);
42 void stop();
43};
45
46#if QT_CORE_INLINE_IMPL_SINCE(6, 5)
47void QBasicTimer::start(int msec, QObject *obj)
48{
49 start(std::chrono::milliseconds{msec}, obj);
50}
51
53{
54 start(std::chrono::milliseconds{msec}, t, obj);
55}
56#endif
57
58inline void swap(QBasicTimer &lhs, QBasicTimer &rhs) noexcept { lhs.swap(rhs); }
59
61
62#endif // QBASICTIMER_H
\inmodule QtCore
Definition qbasictimer.h:18
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
QBasicTimer(QBasicTimer &&other) noexcept
Definition qbasictimer.h:26
~QBasicTimer()
Destroys the basic timer.
Definition qbasictimer.h:24
int timerId() const noexcept
Returns the timer's ID.
Definition qbasictimer.h:35
bool isActive() const noexcept
Returns true if the timer is running and has not been stopped; otherwise returns false.
Definition qbasictimer.h:34
constexpr QBasicTimer() noexcept
Constructs a basic timer.
Definition qbasictimer.h:23
\inmodule QtCore
Definition qobject.h:103
Combined button and popup list for selecting options.
Definition qcompare.h:63
TimerType
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
GLenum GLuint id
[7]
GLuint start
GLhandleARB obj
[2]
GLdouble GLdouble t
Definition qopenglext.h:243
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:158
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
QSharedPointer< T > other(t)
[5]
this swap(other)