![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qbasictimer.h>
Public Types | |
using | Duration = QAbstractEventDispatcher::Duration |
A {std::chrono::duration} type that is used in various API in this class. |
Public Member Functions | |
constexpr | QBasicTimer () noexcept |
Constructs a basic timer. | |
~QBasicTimer () | |
Destroys the basic timer. | |
QBasicTimer (QBasicTimer &&other) noexcept | |
void | swap (QBasicTimer &other) noexcept |
bool | isActive () const noexcept |
Returns true if the timer is running and has not been stopped; otherwise returns false . | |
int | timerId () const noexcept |
\obsolete | |
Qt::TimerId | id () const noexcept |
void | start (int msec, QObject *obj) |
\obsolete Use chrono overload instead. | |
void | start (int msec, Qt::TimerType timerType, QObject *obj) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. \obsolete. | |
void | start (Duration duration, QObject *obj) |
void | start (Duration duration, Qt::TimerType timerType, QObject *obj) |
void | stop () |
Stops the timer. |
Related Symbols | |
(Note that these are not member symbols.) | |
swap (QBasicTimer &lhs, QBasicTimer &rhs) |
\inmodule QtCore
The QBasicTimer class provides timer events for objects.
This is a fast, lightweight, and low-level class used by Qt internally. We recommend using the higher-level QTimer class rather than this class if you want to use timers in your applications. Note that this timer is a repeating timer that will send subsequent timer events unless the stop() function is called.
To use this class, create a QBasicTimer, and call its start() function with a timeout interval and with a pointer to a QObject subclass. When the timer times out it will send a timer event to the QObject subclass. The timer can be stopped at any time using stop(). isActive() returns true
for a timer that is running; i.e. it has been started, has not reached the timeout time, and has not been stopped. The timer's ID can be retrieved using timerId().
Objects of this class cannot be copied, but can be moved, so you can maintain a list of basic timers by holding them in container that supports move-only types, e.g. std::vector.
Definition at line 18 of file qbasictimer.h.
A {std::chrono::duration} type that is used in various API in this class.
This type exists to facilitate a possible transition to a higher or lower granularity.
In all current platforms, it is nanoseconds
.
Definition at line 25 of file qbasictimer.h.
|
inlineconstexprnoexcept |
|
inline |
Destroys the basic timer.
Definition at line 28 of file qbasictimer.h.
|
inlinenoexcept |
Move-constructs a basic timer from other, which is left \l{isActive()}{inactive}.
Definition at line 30 of file qbasictimer.h.
|
inlinenoexcept |
Returns the timer's ID.
Definition at line 40 of file qbasictimer.h.
|
inlinenoexcept |
Returns true
if the timer is running and has not been stopped; otherwise returns false
.
Definition at line 38 of file qbasictimer.h.
Definition at line 50 of file qbasictimer.h.
void QBasicTimer::start | ( | Duration | duration, |
Qt::TimerType | timerType, | ||
QObject * | obj ) |
Starts (or restarts) the timer with a duration timeout and the given timerType. See Qt::TimerType for information on the different timer types.
negative-intervals-not-allowed
obj will receive timer events.
start-nanoseconds-note
Definition at line 185 of file qbasictimer.cpp.
void QBasicTimer::start | ( | int | msec, |
Qt::TimerType | timerType, | ||
QObject * | obj ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. \obsolete.
\fn void QBasicTimer::start(Duration duration, QObject *object) \since 6.5 Starts (or restarts) the timer with a \a duration timeout. The timer will be a Qt::CoarseTimer. See Qt::TimerType for information on the different timer types. The given \a object will receive timer events. \include timers-common.qdocinc negative-intervals-not-allowed
! [start-nanoseconds-note]
\sa stop(), isActive(), QObject::timerEvent(), Qt::CoarseTimer
Use chrono overload instead.
void QBasicTimer::stop | ( | ) |
|
inlinenoexcept |
Definition at line 36 of file qbasictimer.h.
|
inlinenoexcept |
\obsolete
Returns the timer's ID.
In new code use id() instead.
Definition at line 39 of file qbasictimer.h.
|
Swaps the timer lhs with rhs. This operation is very fast and never fails.
Definition at line 69 of file qbasictimer.h.