diff options
Diffstat (limited to 'src/corelib/kernel/qbasictimer.h')
-rw-r--r-- | src/corelib/kernel/qbasictimer.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/corelib/kernel/qbasictimer.h b/src/corelib/kernel/qbasictimer.h index e3a41822de..ccc93f6e9b 100644 --- a/src/corelib/kernel/qbasictimer.h +++ b/src/corelib/kernel/qbasictimer.h @@ -7,6 +7,8 @@ #include <QtCore/qglobal.h> #include <QtCore/qnamespace.h> +#include <chrono> + QT_BEGIN_NAMESPACE @@ -22,7 +24,7 @@ public: inline ~QBasicTimer() { if (id) stop(); } QBasicTimer(QBasicTimer &&other) noexcept - : id{qExchange(other.id, 0)} + : id{std::exchange(other.id, 0)} {} QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QBasicTimer) @@ -31,13 +33,28 @@ public: bool isActive() const noexcept { return id != 0; } int timerId() const noexcept { return id; } - + QT_CORE_INLINE_SINCE(6, 5) void start(int msec, QObject *obj); + QT_CORE_INLINE_SINCE(6, 5) void start(int msec, Qt::TimerType timerType, QObject *obj); + void start(std::chrono::milliseconds duration, QObject *obj); + void start(std::chrono::milliseconds duration, Qt::TimerType timerType, QObject *obj); void stop(); }; Q_DECLARE_TYPEINFO(QBasicTimer, Q_RELOCATABLE_TYPE); +#if QT_CORE_INLINE_IMPL_SINCE(6, 5) +void QBasicTimer::start(int msec, QObject *obj) +{ + start(std::chrono::milliseconds{msec}, obj); +} + +void QBasicTimer::start(int msec, Qt::TimerType t, QObject *obj) +{ + start(std::chrono::milliseconds{msec}, t, obj); +} +#endif + inline void swap(QBasicTimer &lhs, QBasicTimer &rhs) noexcept { lhs.swap(rhs); } QT_END_NAMESPACE |