Timer¶
Description¶
The Timer object implements a timer which triggers periodically or only once. Property repeat controls the behaviour.
› Inherits: | Object |
---|
Properties¶
interval¶
This property holds the interval which elapses before triggered() is emitted. The minimum value is 1
.
› Type: | SignedInteger |
---|---|
› Default: | 1000 |
› Signal: | intervalChanged() |
› Attributes: | Writable |
msecsElapsed¶
This property holds returns the number of milliseconds since this timer was last started.
› Type: | SignedBigInteger |
---|---|
› Attributes: | Readonly |
repeat¶
This property holds whether the timer triggers only once (repeat set to false
) or repeatedly.
› Type: | Boolean |
---|---|
› Default: | true |
› Signal: | repeatChanged() |
› Attributes: | Writable |
running¶
This property holds whether the timer is running. Setting this property equals to calling start() or stop().
› Type: | Boolean |
---|---|
› Default: | true |
› Signal: | runningChanged() |
› Attributes: | Writable |
triggeredOnStart¶
This property holds whether the timer sends a triggered() signal when the timer is started.
› Type: | Boolean |
---|---|
› Default: | false |
› Signal: | triggeredOnStartChanged() |
› Attributes: | Writable |
triggeredOnStop¶
This property holds whether the timer sends a triggered() signal after the timer is stopped.
› Type: | Boolean |
---|---|
› Default: | false |
› Signal: | triggeredOnStopChanged() |
› Attributes: | Writable |
Methods¶
Signals¶
Example¶
import InCore.Foundation 2.5
Application {
//minimal Timer with default values
Timer {
onTriggered: console.log( "i am a minimal Timer" )
}
Timer {
repeat: false
interval: 10000
onTriggered: console.log( "i trigger only once after a while" )
}
Timer {
id: testTimer
interval: 500
onTriggered: console.log( "i am running fast" )
}
Timer {
id: onOffTimer
interval: 2000
onTriggered: {
console.log( "switching testTimer", testTimer.running ? "off" : "on" )
testTimer.running = !testTimer.running
}
}
}