QBasicTimer Class
The QBasicTimer class provides timer events for objects. More…
| Header | #include <QBasicTimer> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Functions
| QBasicTimer() | |
| ~QBasicTimer() | |
| QBasicTimer(QBasicTimer &&o) | |
| QBasicTimer & | operator=(QBasicTimer &&o) |
| bool | isActive() const |
| int | timerId() const |
| Qt::TimerId | id() const |
| void | start(int msec, QObject *object) |
| void | start(int msec, Qt::TimerType, QObject *object) |
| void | start(std::chrono::milliseconds interval, QObject *object) |
| void | start(std::chrono::milliseconds interval, Qt::TimerType, QObject *object) |
| void | stop() |
Detailed Description
A QBasicTimer is a lightweight wrapper around QObject::startTimer() and QObject::killTimer(). Unlike QTimer it emits no signal; the object passed to start() receives a QTimerEvent in QObject::timerEvent(). The timer is stopped when the QBasicTimer is destroyed, or if the object is deleted.
See also QTimer, QTimerEvent and QObject::startTimer().
Differences from Qt
The Qt::TimerType argument is accepted but ignored. There is no remainingTime().
Member Function Documentation
QBasicTimer::QBasicTimer()
Constructs a timer that is not running.
QBasicTimer::QBasicTimer(QBasicTimer &&o)
Move-constructs a timer from o, taking over its running timer and leaving o stopped.
QBasicTimer::~QBasicTimer()
Destroys the timer, stopping it if it is running.
Qt::TimerId QBasicTimer::id() const
Returns the identifier of the timer as a Qt::TimerId, or Qt::TimerId::Invalid if it is not running.
This function was introduced in 6.8.
See also timerId().
bool QBasicTimer::isActive() const
Returns true if the timer is running; otherwise returns false.
See also timerId().
QBasicTimer & QBasicTimer::operator=(QBasicTimer &&o)
Move-assigns o to this timer. This timer is stopped first, then it takes over the running timer of o, which is left stopped.
void QBasicTimer::start(int msec, QObject *object)
Starts the timer with a timeout of msec milliseconds. object receives a QTimerEvent each time the timer fires. A running timer is stopped first. If msec is negative or object is nullptr the timer does not start.
See also stop().
void QBasicTimer::start(int msec, Qt::TimerType, QObject *object)
This is an overloaded function.
Starts the timer with a timeout of msec milliseconds. The timer type is ignored.
void QBasicTimer::start(std::chrono::milliseconds interval, QObject *object)
This is an overloaded function.
Starts the timer with the timeout interval, sending the timer events to object.
void QBasicTimer::start(std::chrono::milliseconds interval, Qt::TimerType, QObject *object)
This is an overloaded function.
Starts the timer with the timeout interval. The timer type is ignored.
void QBasicTimer::stop()
Stops the timer. Does nothing if it is not running.
See also start().
int QBasicTimer::timerId() const
Returns the identifier of the timer, or 0 if it is not running. The identifier is the one delivered in QTimerEvent::timerId().