QML Example Use timer to update Date: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Add "cleanup" tag)
(Cleanup)
 
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
{{LangSwitch}}
 
[[Category:Developing_with_Qt::Qt Quick]]
[[Category:Developing_with_Qt::Qt Quick]]
= Overview =
An example demonstrating how Timer can be used to update Date() in a Text by updating it continuously using a timer.
An example demonstrating how Timer can be used to update Date() in a Text by updating it continuously using a timer.


<code>import QtQuick 1.0
<code>
import QtQuick 1.0


Rectangle {
Rectangle {
id: main
    id: main
width: 600; height: 300
    width: 600
    height: 300


Text {
    Text {
id: foo
        id: foo
font.pointSize: 12
        font.pointSize: 12
function set(){
        function set() {
foo.text = Date();
            foo.text = Date()
}
        }
}
    }


Timer {
    Timer {
id: textTimer
        id: textTimer
interval: 1000
        interval: 1000
repeat: true
        repeat: true
running: true
        running: true
triggeredOnStart: true
        triggeredOnStart: true
onTriggered: {
        onTriggered: foo.set()
foo.set();
    }
}
}
}
}
</code>

Latest revision as of 22:08, 28 June 2015

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

An example demonstrating how Timer can be used to update Date() in a Text by updating it continuously using a timer.

import QtQuick 1.0

Rectangle {
    id: main
    width: 600
    height: 300

    Text {
        id: foo
        font.pointSize: 12
        function set() {
            foo.text = Date()
        }
    }

    Timer {
        id: textTimer
        interval: 1000
        repeat: true
        running: true
        triggeredOnStart: true
        onTriggered: foo.set()
    }
}