sincerely Singaporean

If you have not done so, read this full tutorial on how to use SGEXTN to build an application.

SGXTimer

see header file

see source file

class SGXTimer;

part of SGEXTN module SG_Core

timer for delayed and repeated execution of functions

detailed description

list of all including inherited members

implementation details

preprocessor file inclusion directive: #include ‹SGXTimer.h›

CMake target for BuildLah: SGEXTN::SG_Core

see this link for more information about BuildLah

parent class: (none)

children classes: (none)

instance member variables

void (*attachedFunction)();

instance member functions

SGXTimer(float t, void (*attachedFunction)());

void deleteTimer();

void start() const;

void stop() const;

static member functions

static void singleCall(float t, void (*attachedFunction)());

Detailed Description

SGXTimer provides a timer that takes a callback function ⁽㈳㈴㈳㈮㈱㈨㈠㈫ ㈧㈤㈱㈤⁾ which can be either run after a specified amount of time have passed or be run at a regular interval.

Implementation Details

wrapper of QTimer

void (*attachedFunction)();

callback function ⁽㈳㈴㈳㈮㈱㈨㈠㈫ ㈧㈤㈱㈤⁾ attached to this SGXTimer.

This is set automatically by the constructor. Only set it explicitly if you want to change the callback function ⁽㈳㈴㈳㈮㈱㈨㈠㈫ ㈧㈤㈱㈤⁾ attached to an ongoing SGXTimer.

Setting this to nullptr is undefined behaviour. Use SGXTimer::stop if you want to stop an ongoing SGXTimer.

SGXTimer(float t, void (*attachedFunction)());

Creates and starts a SGXTimer running attachedFunction every t seconds.

Pass 0 to t to run attachedFunction on every frame, this may significantly increase power consumption of your application.

The timer is automatically started upon creation.

attachedFunction being nullptr will crash.

t being negative will crash.

Directly deleting a SGXTimer will crash as not preventing it would lead to a use after free bug.

void deleteTimer();

Deletes the SGXTimer safely.

Directly deleting a SGXTimer will crash as not preventing it would lead to a use after free bug.

void start() const;

Restarts this SGXTimer which is previously paused.

If this SGXTimer was not previously paused, this restarts the time.

void stop() const;

Pauses this SGXTimer. The timer can be resumed using SGXTimer::start later.

Restarting a SGXTimer using SGXTimer::start resets the time.

static void singleCall(float t, void (*attachedFunction)());

Runs attachedFunction after t seconds once without repeating it.

Pass 0 to t to run attachedFunction immediately after this frame.

The SGXTimer object controlling this is not exposed, so you cannot stop or restart this timer.

attachedFunction being nullptr will crash.

t being negative will crash.

©2025 05524F.sg (Singapore)

contact 05524F / report a bug / make a suggestion

about 05524F SINGAPORE values

list of 05524F projects