From ef60ed1c9dbc87d9f8401036cc254a9c45cd8ca8 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Dec 2011 11:32:43 +0100 Subject: Add Qt::TimerType and the QTimer::timerType property The timer type will control the accuracy of the timer. By default, all timers are CoarseTimers, which allows for +/- 5% interval adjustment. PreciseTimers will not have any interval adjustments, VeryCoarseTimers will have intervals adjusted to full second resolution. Use QTimer::setTimerType() or the QTimer::singleShot() overload to specify the type. QObject::startTimer() now takes a Qt::TimerType argument which defaults to Qt::CoarseTimer. QBasicTimer::startTimer() gets an overload that takes a Qt::TimerType argument. The argument is unused for now, since the QAbstractEventDispatcher interface needs to change (done in a separate commit). Author: Thiago Macieira Change-Id: I3100da5aa1fe17ec30b8644897d0fe6ec4a07f52 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qbasictimer.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qbasictimer.cpp') diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp index 8efeea6fae..d91c5a9ffe 100644 --- a/src/corelib/kernel/qbasictimer.cpp +++ b/src/corelib/kernel/qbasictimer.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include "qbasictimer.h" -#include "qcoreapplication.h" #include "qabstracteventdispatcher.h" QT_BEGIN_NAMESPACE @@ -120,6 +119,24 @@ void QBasicTimer::start(int msec, QObject *obj) id = obj->startTimer(msec); } +/*! + \overload + + Starts (or restarts) the timer with a \a msec milliseconds timeout and the + given \a timerType. See Qt::TimerType for information on the different + timer types. + + The given \a object will receive timer events. + + \sa stop() isActive() QObject::timerEvent() Qt::TimerType + */ +void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj) +{ + stop(); + if (obj) + id = obj->startTimer(msec, timerType); +} + /*! Stops the timer. -- cgit v1.2.3