diff options
author | Anton Kudryavtsev <antkudr@mail.ru> | 2016-11-28 21:29:22 +0300 |
---|---|---|
committer | Anton Kudryavtsev <antkudr@mail.ru> | 2016-12-23 18:08:53 +0000 |
commit | 6d1d66a0429d2eb36beb192112b9a7bb8ae00b9a (patch) | |
tree | 2176395ae84038d4a298f668dd58780da0620671 /src/corelib/kernel/qobject.cpp | |
parent | 3e7f42cb81cacd7e07c20a69ae3e86e5316e2b99 (diff) |
QObject: add startTimer() overload with std::chrono
In client code I often see code like:
startTimer(1000); //ms
Let the code to be self-explaining. So provide overload
method that takes std::chrono::milliseconds as arg.
QTimer already has std::chrono support, but QObject does not.
Change-Id: Ib348612ce35f1a997b4816fe9e864775cbcbec16
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index fd1c767b4c..ac1b2d41bf 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1634,6 +1634,45 @@ int QObject::startTimer(int interval, Qt::TimerType timerType) } /*! + \since 5.9 + \overload + \fn int QObject::startTimer(std::chrono::milliseconds time, Qt::TimerType timerType) + + Starts a timer and returns a timer identifier, or returns zero if + it could not start a timer. + + A timer event will occur every \a time interval until killTimer() + is called. If \a interval is equal to \c{std::chrono::duration::zero()}, + then the timer event occurs once every time there are no more window + system events to process. + + The virtual timerEvent() function is called with the QTimerEvent + event parameter class when a timer event occurs. Reimplement this + function to get timer events. + + If multiple timers are running, the QTimerEvent::timerId() can be + used to find out which timer was activated. + + Example: + + \snippet code/src_corelib_kernel_qobject.cpp 8 + + Note that QTimer's accuracy depends on the underlying operating system and + hardware. The \a timerType argument allows you to customize the accuracy of + the timer. See Qt::TimerType for information on the different timer types. + Most platforms support an accuracy of 20 milliseconds; some provide more. + If Qt is unable to deliver the requested number of timer events, it will + silently discard some. + + The QTimer class provides a high-level programming interface with + single-shot timers and timer signals instead of events. There is + also a QBasicTimer class that is more lightweight than QTimer and + less clumsy than using timer IDs directly. + + \sa timerEvent(), killTimer(), QTimer::singleShot() +*/ + +/*! Kills the timer with timer identifier, \a id. The timer identifier is returned by startTimer() when a timer |