C
Timer QML Type
Triggers a handler at a specified interval. More...
Import Statement: | import QtQuick |
Properties
Signals
Methods
Detailed Description
A Timer can be used to trigger an action either once, or repeatedly at a given interval. It wraps Qul::Timer.
Here is a Timer that shows the current date and time, and updates the text every 500 milliseconds.
import QtQuick 2.15 Rectangle { color: "white" property int counter: 0 Timer { interval: 500; running: true; repeat: true onTriggered: counter += 1 } Text { id: label; text: counter } }
The Timer type is synchronized with the animation timer. As the animation timer is usually set to 60fps, the resolution of Timer will be at best 16ms.
Property Documentation
interval : int |
Sets the interval between triggers, in milliseconds.
The default interval is 1000 milliseconds.
repeat : bool |
running : bool |
If set to true
, starts the timer; otherwise stops the timer. For a non-repeating timer, running is set to false
after the timer has been triggered.
Note: It is set to false
by default.
See also repeat.
Signal Documentation
triggered() |
This signal is emitted when the Timer times out.
Note: The corresponding handler is onTriggered
.
Method Documentation
restart() |
Restarts the timer
The Timer is started if it is not running, otherwise it is stopped, reset to its initial state, and started. The running
property is set to true
after calling restart()
.
start() |
Starts the timer
If the timer is already running, calling this method has no effect. The running
property is set to true
after calling start()
.
stop() |
Stops the timer
If the timer is not running, calling this method has no effect. The running
property is set to false
after calling stop()
.
Available under certain Qt licenses.
Find out more.