Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QBasicTimer Class Reference

\inmodule QtCore More...

#include <qbasictimer.h>

+ Collaboration diagram for QBasicTimer:

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
 Returns the timer's ID.
 
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 (std::chrono::milliseconds duration, QObject *obj)
 
void start (std::chrono::milliseconds 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)
 

Detailed Description

\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.

See also
QTimer, QChronoTimer, QTimerEvent, QObject::timerEvent(), Timers, {Affine Transformations}

Definition at line 17 of file qbasictimer.h.

Constructor & Destructor Documentation

◆ QBasicTimer() [1/2]

QBasicTimer::QBasicTimer ( )
inlineconstexprnoexcept

Constructs a basic timer.

See also
start()

Definition at line 23 of file qbasictimer.h.

◆ ~QBasicTimer()

QBasicTimer::~QBasicTimer ( )
inline

Destroys the basic timer.

Definition at line 24 of file qbasictimer.h.

◆ QBasicTimer() [2/2]

QBasicTimer::QBasicTimer ( QBasicTimer && other)
inlinenoexcept
Since
5.14

Move-constructs a basic timer from other, which is left \l{isActive()}{inactive}.

See also
isActive(), swap()

Definition at line 26 of file qbasictimer.h.

References other().

+ Here is the call graph for this function:

Member Function Documentation

◆ isActive()

◆ start() [1/4]

◆ start() [2/4]

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.

Use chrono overload instead.

◆ start() [3/4]

void QBasicTimer::start ( std::chrono::milliseconds duration,
QObject * object )
Since
6.5

Starts (or restarts) the timer with a duration timeout. The timer will be a Qt::CoarseTimer. See Qt::TimerType for information on the different timer types.

The given object will receive timer events.

See also
stop(), isActive(), QObject::timerEvent(), Qt::CoarseTimer

Definition at line 127 of file qbasictimer.cpp.

References Qt::CoarseTimer.

◆ start() [4/4]

void QBasicTimer::start ( std::chrono::milliseconds duration,
Qt::TimerType timerType,
QObject * obj )
Since
6.5

Starts (or restarts) the timer with a duration timeout and the given timerType. See Qt::TimerType for information on the different timer types.

obj will receive timer events.

See also
stop(), isActive(), QObject::timerEvent(), Qt::TimerType

Definition at line 151 of file qbasictimer.cpp.

References QAbstractEventDispatcher::instance(), Q_UNLIKELY, qWarning, QAbstractEventDispatcher::registerTimer(), stop(), and QObject::thread().

+ Here is the call graph for this function:

◆ stop()

void QBasicTimer::stop ( )

Stops the timer.

See also
start(), isActive()

Definition at line 176 of file qbasictimer.cpp.

References QAbstractEventDispatcher::instance(), qWarning, QAbstractEventDispatcherPrivate::releaseTimerId(), and QAbstractEventDispatcher::unregisterTimer().

Referenced by QQuickTextInputPrivate::cancelPasswordEchoTimer(), QNetworkAccessCache::clear(), QTreeModel::clear(), QQuickFlickablePrivate::clearDelayedPress(), QTreeViewPrivate::collapse(), QTreeModel::ensureSorted(), QWaylandQuickShellEventFilter::eventFilter(), QAbstractItemViewPrivate::fetchMore(), QAbstractItemViewPrivate::interruptDelayedItemsLayout(), QQuickPressHandler::mouseMoveEvent(), QWidgetTextControlPrivate::mousePressEvent(), QQuickPressHandler::mousePressEvent(), QQuickPressHandler::mouseReleaseEvent(), QMacPanGestureRecognizer::recognize(), QPollingFileSystemWatcherEngine::removePaths(), QQuickFlickablePrivate::replayDelayedPress(), QMacPanGestureRecognizer::reset(), QHeaderViewPrivate::resizeSections(), QTipLabel::restartExpireTimer(), QMenuBarPrivate::setCurrentAction(), QTreeModel::sort(), start(), QNmeaPositionInfoSourcePrivate::startUpdates(), QNmeaSatelliteInfoSourcePrivate::startUpdates(), QMenuPrivate::DelayState::stop(), QQuickToolTipPrivate::stopDelay(), QQuickToolTipPrivate::stopTimeout(), QMenuSloppyState::stopTimer(), QNmeaPositionInfoSourcePrivate::stopUpdates(), QNmeaSatelliteInfoSourcePrivate::stopUpdates(), QPulseAudioSource::suspend(), QTipLabel::timerEvent(), QMacPanGestureRecognizer::timerEvent(), QQuickPressHandler::timerEvent(), QQuickTapHandler::timerEvent(), QQC2::QWindowsStyle::timerEvent(), QWaylandQuickShellEventFilter::timerEvent(), QComboBoxPrivateContainer::timerEvent(), QWidgetTextControlPrivate::updateCursorBlinking(), QQuickTextControlPrivate::updateCursorFlashTime(), and QQuickTapHandler::wantsEventPoint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

QBasicTimer::swap ( QBasicTimer & other)
inlinenoexcept
Since
5.14

Swaps the timer other with this timer. This operation is very fast and never fails.

Definition at line 32 of file qbasictimer.h.

References other().

+ Here is the call graph for this function:

◆ timerId()

Friends And Related Symbol Documentation

◆ swap()

swap ( QBasicTimer & lhs,
QBasicTimer & rhs )
related
Since
5.14

Swaps the timer lhs with rhs. This operation is very fast and never fails.

Definition at line 58 of file qbasictimer.h.


The documentation for this class was generated from the following files: