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.h | |
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.h')
-rw-r--r-- | src/corelib/kernel/qobject.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 25acdefeaf..d42eb2a13d 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -55,6 +55,10 @@ #include <QtCore/qobject_impl.h> +#if QT_HAS_INCLUDE(<chrono>) +# include <chrono> +#endif + QT_BEGIN_NAMESPACE @@ -150,6 +154,13 @@ public: void moveToThread(QThread *thread); int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer); +#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC) + Q_ALWAYS_INLINE + int startTimer(std::chrono::milliseconds time, Qt::TimerType timerType = Qt::CoarseTimer) + { + return startTimer(int(time.count()), timerType); + } +#endif void killTimer(int id); template<typename T> |