The Timer item triggers a handler at a specified interval. More...
This element was introduced in Qt 4.7.
A Timer can be used to trigger an action either once, or repeatedly at a given interval.
Here is a Timer that shows the current date and time, and updates the text every 500 milliseconds. It uses the JavaScript Date object to access the current time.
import QtQuick 1.0 Item { Timer { interval: 500; running: true; repeat: true onTriggered: time.text = Date().toString() } Text { id: time } }
The Timer element is synchronized with the animation timer. Since the animation timer is usually set to 60fps, the resolution of Timer will be at best 16ms.
If the Timer is running and one of its properties is changed, the elapsed time will be reset. For example, if a Timer with interval of 1000ms has its repeat property changed 500ms after starting, the elapsed time will be reset to 0, and the Timer will be triggered 1000ms later.
See also Clocks example.
interval : int |
Sets the interval between triggers, in milliseconds.
The default interval is 1000 milliseconds.
repeat : bool |
If repeat is true the timer is triggered repeatedly at the specified interval; otherwise, the timer will trigger once at the specified interval and then stop (i.e. running will be set to false).
repeat defaults to false.
See also running.
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.
running defaults to false.
See also repeat.
triggeredOnStart : bool |
When a timer is started, the first trigger is usually after the specified interval has elapsed. It is sometimes desirable to trigger immediately when the timer is started; for example, to establish an initial state.
If triggeredOnStart is true, the timer is triggered immediately when started, and subsequently at the specified interval. Note that if repeat is set to false, the timer is triggered twice; once on start, and again at the interval.
triggeredOnStart defaults to false.
See also running.
Restarts the timer.
If the Timer is not running it will be started, otherwise it will be stopped, reset to initial state and started. The running property will be true following a call to restart().
Starts the timer.
If the timer is already running, calling this method has no effect. The running property will be true following a call to start().
Stops the timer.
If the timer is not running, calling this method has no effect. The running property will be false following a call to stop().
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.