diff options
Diffstat (limited to 'src/corelib/kernel/qbasictimer.cpp')
-rw-r--r-- | src/corelib/kernel/qbasictimer.cpp | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp index 694692013a..17711a355e 100644 --- a/src/corelib/kernel/qbasictimer.cpp +++ b/src/corelib/kernel/qbasictimer.cpp @@ -33,10 +33,8 @@ QT_BEGIN_NAMESPACE can maintain a list of basic timers by holding them in container that supports move-only types, e.g. std::vector. - The \l{widgets/wiggly}{Wiggly} example uses QBasicTimer to repaint - a widget at regular intervals. - - \sa QTimer, QTimerEvent, QObject::timerEvent(), Timers, {Affine Transformations} + \sa QTimer, QChronoTimer, QTimerEvent, QObject::timerEvent(), + Timers, {Affine Transformations} */ @@ -86,10 +84,18 @@ QT_BEGIN_NAMESPACE /*! \fn QBasicTimer::swap(QBasicTimer &other) + \since 5.14 + + Swaps the timer \a other with this timer. + This operation is very fast and never fails. +*/ + +/*! \fn swap(QBasicTimer &lhs, QBasicTimer &rhs) + \relates QBasicTimer \since 5.14 - Swaps string \a other with this string, or \a lhs with \a rhs. + Swaps the timer \a lhs with \a rhs. This operation is very fast and never fails. */ @@ -102,42 +108,50 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QBasicTimer::start(qint64 msec, QObject *object) + \fn void QBasicTimer::start(int msec, QObject *object) + + \obsolete Use chrono overload instead. +*/ - Starts (or restarts) the timer with a \a msec milliseconds timeout. The +/*! + \since 6.5 + + Starts (or restarts) the timer with a \a duration timeout. The timer will be a Qt::CoarseTimer. See Qt::TimerType for information on the different timer types. The given \a object will receive timer events. - \note In Qt versions prior to 6.5, \a msec was \c{int}, not - \c{qint64}. - \sa stop(), isActive(), QObject::timerEvent(), Qt::CoarseTimer */ -void QBasicTimer::start(qint64 msec, QObject *obj) +void QBasicTimer::start(std::chrono::milliseconds duration, QObject *object) { - start(msec, Qt::CoarseTimer, obj); + start(duration, Qt::CoarseTimer, object); } /*! + \fn QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj) \overload + \obsolete + + Use chrono overload instead. +*/ + +/*! + \since 6.5 - Starts (or restarts) the timer with a \a msec milliseconds timeout and the + Starts (or restarts) the timer with a \a duration timeout and the given \a timerType. See Qt::TimerType for information on the different timer types. \a obj will receive timer events. - \note In Qt versions prior to 6.5, \a msec was \c{int}, not - \c{qint64}. - \sa stop(), isActive(), QObject::timerEvent(), Qt::TimerType */ -void QBasicTimer::start(qint64 msec, Qt::TimerType timerType, QObject *obj) +void QBasicTimer::start(std::chrono::milliseconds duration, Qt::TimerType timerType, QObject *obj) { QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); - if (Q_UNLIKELY(msec < 0)) { + if (Q_UNLIKELY(duration.count() < 0)) { qWarning("QBasicTimer::start: Timers cannot have negative timeouts"); return; } @@ -151,7 +165,7 @@ void QBasicTimer::start(qint64 msec, Qt::TimerType timerType, QObject *obj) } stop(); if (obj) - id = eventDispatcher->registerTimer(msec, timerType, obj); + id = int(eventDispatcher->registerTimer(duration, timerType, obj)); } /*! @@ -163,7 +177,7 @@ void QBasicTimer::stop() { if (id) { QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); - if (eventDispatcher && !eventDispatcher->unregisterTimer(id)) { + if (eventDispatcher && !eventDispatcher->unregisterTimer(Qt::TimerId(id))) { qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread"); return; } |