slint::Timer Struct
struct Timer;#include <slint.h>A Timer that can call a callback at repeated interval
Use the static single_shot function to make a single shot timer
Public Functions
Section titled “Public Functions”slint::Timer::Timer()=default
Construct a null timer. Use the start() method to activate the timer with a mode, interval and callback.
slint::Timer::Timer(std::chrono::milliseconds interval, F callback)
Construct a timer which will repeat the callback every interval milliseconds until the destructor of the timer is called.
This is a convenience function and equivalent to calling start(slint::TimerMode::Repeated, interval, callback); on a default constructed Timer.
slint::Timer::Timer(const Timer &)=delete
operator=
Section titled “ operator=”Timer & slint::Timer::operator=(const Timer &)=delete
~Timer
Section titled “ ~Timer”slint::Timer::~Timer()
void slint::Timer::start(TimerMode mode, std::chrono::milliseconds interval, F callback)
Starts the timer with the given mode and interval, in order for the callback to called when the timer fires. If the timer has been started previously and not fired yet, then it will be restarted.
void slint::Timer::stop()
Stops the previously started timer. Does nothing if the timer has never been started. A stopped timer cannot be restarted with restart(). Use start() instead.
restart
Section titled “ restart”void slint::Timer::restart()
Restarts the timer. If the timer was previously started by calling [Self::start()] with a duration and callback, then the time when the callback will be next invoked is re-calculated to be in the specified duration relative to when this function is called.
Does nothing if the timer was never started.
running
Section titled “ running”bool slint::Timer::running() const
Returns true if the timer is running; false otherwise.
interval
Section titled “ interval”std::chrono::milliseconds slint::Timer::interval() const
Returns the interval of the timer. Returns 0 if the timer was never started.
Public Static Functions
Section titled “Public Static Functions” single_shot
Section titled “ single_shot”static void slint::Timer::single_shot(std::chrono::milliseconds duration, F callback)
Call the callback after the given duration.
© 2026 SixtyFPS GmbH