Warning, file /include/QtCore/qbasictimer.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QBASICTIMER_H
0005 #define QBASICTIMER_H
0006
0007 #include <QtCore/qglobal.h>
0008 #include <QtCore/qnamespace.h>
0009
0010 #include <chrono>
0011
0012 QT_BEGIN_NAMESPACE
0013
0014
0015 class QObject;
0016
0017 class Q_CORE_EXPORT QBasicTimer
0018 {
0019 int id;
0020 Q_DISABLE_COPY(QBasicTimer)
0021
0022 public:
0023 constexpr QBasicTimer() noexcept : id{0} {}
0024 inline ~QBasicTimer() { if (id) stop(); }
0025
0026 QBasicTimer(QBasicTimer &&other) noexcept
0027 : id{std::exchange(other.id, 0)}
0028 {}
0029
0030 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QBasicTimer)
0031
0032 void swap(QBasicTimer &other) noexcept { std::swap(id, other.id); }
0033
0034 bool isActive() const noexcept { return id != 0; }
0035 int timerId() const noexcept { return id; }
0036 QT_CORE_INLINE_SINCE(6, 5)
0037 void start(int msec, QObject *obj);
0038 QT_CORE_INLINE_SINCE(6, 5)
0039 void start(int msec, Qt::TimerType timerType, QObject *obj);
0040 void start(std::chrono::milliseconds duration, QObject *obj);
0041 void start(std::chrono::milliseconds duration, Qt::TimerType timerType, QObject *obj);
0042 void stop();
0043 };
0044 Q_DECLARE_TYPEINFO(QBasicTimer, Q_RELOCATABLE_TYPE);
0045
0046 #if QT_CORE_INLINE_IMPL_SINCE(6, 5)
0047 void QBasicTimer::start(int msec, QObject *obj)
0048 {
0049 start(std::chrono::milliseconds{msec}, obj);
0050 }
0051
0052 void QBasicTimer::start(int msec, Qt::TimerType t, QObject *obj)
0053 {
0054 start(std::chrono::milliseconds{msec}, t, obj);
0055 }
0056 #endif
0057
0058 inline void swap(QBasicTimer &lhs, QBasicTimer &rhs) noexcept { lhs.swap(rhs); }
0059
0060 QT_END_NAMESPACE
0061
0062 #endif