Qt 4.8
Timer Class Reference

The Timer item triggers a handler at a specified interval. More...

Detailed Description

The Timer item triggers a handler at a specified interval.

Since
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 {
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
{declarative/toys/clocks}{Clocks example}

The documentation for this class was generated from the following file: