78 |
78 |
79 Here is a timer that shows the current date and time, and updates |
79 Here is a timer that shows the current date and time, and updates |
80 the text every 500 milliseconds: |
80 the text every 500 milliseconds: |
81 |
81 |
82 \qml |
82 \qml |
83 Timer { |
83 import Qt 4.7 |
84 interval: 500; running: true; repeat: true |
84 |
85 onTriggered: time.text = Date().toString() |
85 Item { |
86 } |
86 Timer { |
87 Text { |
87 interval: 500; running: true; repeat: true |
88 id: time |
88 onTriggered: time.text = Date().toString() |
|
89 } |
|
90 |
|
91 Text { |
|
92 id: time |
|
93 } |
89 } |
94 } |
90 \endqml |
95 \endqml |
91 |
96 |
92 QDeclarativeTimer is synchronized with the animation timer. Since the animation |
97 The Timer element is synchronized with the animation timer. Since the animation |
93 timer is usually set to 60fps, the resolution of QDeclarativeTimer will be |
98 timer is usually set to 60fps, the resolution of Timer will be |
94 at best 16ms. |
99 at best 16ms. |
95 |
100 |
96 If the Timer is running and one of its properties is changed, the |
101 If the Timer is running and one of its properties is changed, the |
97 elapsed time will be reset. For example, if a Timer with interval of |
102 elapsed time will be reset. For example, if a Timer with interval of |
98 1000ms has its \e repeat property changed 500ms after starting, the |
103 1000ms has its \e repeat property changed 500ms after starting, the |
99 elapsed time will be reset to 0, and the Timer will be triggered |
104 elapsed time will be reset to 0, and the Timer will be triggered |
100 1000ms later. |
105 1000ms later. |
101 |
106 |
102 \sa {QtDeclarative} |
107 \sa {declarative/toys/clocks}{Clocks example} |
103 */ |
108 */ |
104 |
109 |
105 QDeclarativeTimer::QDeclarativeTimer(QObject *parent) |
110 QDeclarativeTimer::QDeclarativeTimer(QObject *parent) |
106 : QObject(*(new QDeclarativeTimerPrivate), parent) |
111 : QObject(*(new QDeclarativeTimerPrivate), parent) |
107 { |
112 { |