23 Q_PROPERTY(
bool singleShot READ isSingleShot WRITE setSingleShot
24 BINDABLE bindableSingleShot FINAL)
25 Q_PROPERTY(std::chrono::nanoseconds interval READ interval WRITE setInterval
26 BINDABLE bindableInterval FINAL)
27 Q_PROPERTY(std::chrono::nanoseconds remainingTime READ remainingTime FINAL)
28 Q_PROPERTY(Qt::TimerType timerType READ timerType WRITE setTimerType
29 BINDABLE bindableTimerType FINAL)
30 Q_PROPERTY(
bool active READ isActive STORED
false BINDABLE bindableActive FINAL)
32 template <
typename Functor>
33 using FunctorContext =
typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType;
36 explicit QChronoTimer(std::chrono::nanoseconds nsec, QObject *parent =
nullptr);
37 explicit QChronoTimer(QObject *parent =
nullptr);
38 ~QChronoTimer() override;
40 bool isActive()
const;
41 QBindable<
bool> bindableActive();
42 Qt::TimerId id()
const;
44 void setInterval(std::chrono::nanoseconds nsec);
45 std::chrono::nanoseconds interval()
const;
46 QBindable<std::chrono::nanoseconds> bindableInterval();
48 std::chrono::nanoseconds remainingTime()
const;
50 void setTimerType(Qt::TimerType atype);
51 Qt::TimerType timerType()
const;
52 QBindable<Qt::TimerType> bindableTimerType();
54 void setSingleShot(
bool singleShot);
55 bool isSingleShot()
const;
56 QBindable<
bool> bindableSingleShot();
59 template <
typename Functor>
60 QMetaObject::Connection callOnTimeout(
const QObject *context, Functor &&slot,
61 Qt::ConnectionType connectionType = Qt::AutoConnection);
63 template <
typename ... Args>
64 QMetaObject::Connection callOnTimeout(Args && ...args)
66 return QObject::connect(
this, &QChronoTimer::timeout, std::forward<Args>(args)... );
75 void timeout(QPrivateSignal);
78 void timerEvent(QTimerEvent *) override;
81 Q_DISABLE_COPY(QChronoTimer)
84 inline QTimerPrivate *d_func()
noexcept
85 { Q_CAST_IGNORE_ALIGN(
return reinterpret_cast<QTimerPrivate *>(qGetPtrHelper(d_ptr));) }
86 inline const QTimerPrivate *d_func()
const noexcept
87 { Q_CAST_IGNORE_ALIGN(
return reinterpret_cast<
const QTimerPrivate *>(qGetPtrHelper(d_ptr));) }
90 int startTimer(std::chrono::nanoseconds) =
delete;
91 void killTimer(
int) =
delete;