22 Q_PROPERTY(
bool singleShot READ isSingleShot WRITE setSingleShot
23 BINDABLE bindableSingleShot FINAL)
24 Q_PROPERTY(
std::chrono::nanoseconds interval READ interval WRITE setInterval
25 BINDABLE bindableInterval FINAL)
26 Q_PROPERTY(
std::chrono::nanoseconds remainingTime READ remainingTime FINAL)
27 Q_PROPERTY(
Qt::TimerType timerType READ timerType WRITE setTimerType
28 BINDABLE bindableTimerType FINAL)
32 using FunctorContext = typename
QtPrivate::ContextTypeForFunctor<
Functor>::ContextType;
41 Qt::TimerId
id() const;
43 void setInterval(
std::chrono::nanoseconds nsec);
44 std::chrono::nanoseconds interval() const;
47 std::chrono::nanoseconds remainingTime() const;
49 void setTimerType(
Qt::TimerType atype);
50 Qt::TimerType timerType() const;
53 void setSingleShot(
bool singleShot);
54 bool isSingleShot() const;
59 template <
typename Functor>
60 static inline void singleShot(std::chrono::nanoseconds interval,
62 template <
typename Functor>
63 static inline void singleShot(std::chrono::nanoseconds interval interval,
67 template <
typename Functor>
68 static void singleShot(std::chrono::nanoseconds interval,
69 const FunctorContext<Functor> *receiver,
Functor &&slot)
71 singleShot(interval, defaultTimerTypeFor(interval), receiver, std::forward<Functor>(slot));
73 template <
typename Functor>
75 const FunctorContext<Functor> *receiver,
Functor &&slot)
77 using Prototype =
void(*)();
78 auto *slotObj = QtPrivate::makeCallableObject<Prototype>(std::forward<Functor>(slot));
79 singleShotImpl(interval, timerType, receiver, slotObj);
83 template <
typename Functor>
86 { singleShot(interval, timerType,
nullptr, std::forward<Functor>(slot)); }
88 template <
typename Functor>
91 singleShot(interval, defaultTimerTypeFor(interval),
nullptr, std::forward<Functor>(slot));
94 static void singleShot(std::chrono::nanoseconds interval,
Qt::TimerType timerType,
95 const QObject *receiver,
const char *member);
98 { singleShot(interval, defaultTimerTypeFor(interval), receiver, member); }
101 template <
typename Functor>
105 template <
typename ... Args>
132 int startTimer(std::chrono::nanoseconds) =
delete;
133 void killTimer(
int) =
delete;
135 static constexpr Qt::TimerType defaultTimerTypeFor(std::chrono::nanoseconds interval)
noexcept
137 using namespace std::chrono_literals;
141 static void singleShotImpl(std::chrono::nanoseconds interval,
Qt::TimerType timerType,
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe