24 Q_PROPERTY(
bool singleShot READ isSingleShot WRITE setSingleShot
25 BINDABLE bindableSingleShot FINAL)
26 Q_PROPERTY(std::chrono::nanoseconds interval READ interval WRITE setInterval
27 BINDABLE bindableInterval FINAL)
28 Q_PROPERTY(std::chrono::nanoseconds remainingTime READ remainingTime FINAL)
29 Q_PROPERTY(Qt::TimerType timerType READ timerType WRITE setTimerType
30 BINDABLE bindableTimerType FINAL)
31 Q_PROPERTY(
bool active READ isActive STORED
false BINDABLE bindableActive FINAL)
33 template <
typename Functor>
34 using FunctorContext =
typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType;
37 explicit QChronoTimer(std::chrono::nanoseconds nsec, QObject *parent =
nullptr);
38 explicit QChronoTimer(QObject *parent =
nullptr);
39 ~QChronoTimer() override;
41 bool isActive()
const;
42 QBindable<
bool> bindableActive();
43 Qt::TimerId id()
const;
45 void setInterval(std::chrono::nanoseconds nsec);
46 std::chrono::nanoseconds interval()
const;
47 QBindable<std::chrono::nanoseconds> bindableInterval();
49 std::chrono::nanoseconds remainingTime()
const;
51 void setTimerType(Qt::TimerType atype);
52 Qt::TimerType timerType()
const;
53 QBindable<Qt::TimerType> bindableTimerType();
55 void setSingleShot(
bool singleShot);
56 bool isSingleShot()
const;
57 QBindable<
bool> bindableSingleShot();
60 template <
typename Functor>
61 QMetaObject::Connection callOnTimeout(
const QObject *context, Functor &&slot,
62 Qt::ConnectionType connectionType = Qt::AutoConnection);
64 template <
typename ... Args>
65 QMetaObject::Connection callOnTimeout(Args && ...args)
67 return QObject::connect(
this, &QChronoTimer::timeout, std::forward<Args>(args)... );
76 void timeout(QPrivateSignal);
79 void timerEvent(QTimerEvent *) override;
82 Q_DISABLE_COPY(QChronoTimer)
85 inline QTimerPrivate *d_func()
noexcept
86 { Q_CAST_IGNORE_ALIGN(
return reinterpret_cast<QTimerPrivate *>(qGetPtrHelper(d_ptr));) }
87 inline const QTimerPrivate *d_func()
const noexcept
88 { Q_CAST_IGNORE_ALIGN(
return reinterpret_cast<
const QTimerPrivate *>(qGetPtrHelper(d_ptr));) }
91 int startTimer(std::chrono::nanoseconds) =
delete;
92 void killTimer(
int) =
delete;