I have a QML application in which I am trying to create a box with simple clocks that display the current time - similar to the ones that exist on each operating system.
It is assumed that the time should be presented to the user as text in a format hh:mm, for example, 16:12.
I am currently trying to find a solution with the Timer component running during the life of the application and updating the text by calling:
timeText.text = Qt.formatTime(new Date(),"hh:mm")
every 60 seconds. Is there a better way to do this or to use the Timer component .
Snippet of the whole code:
Text {
id: timeText
x: 10
y: 10
text: Qt.formatTime(new Date(),"hh:mm")
}
Timer {
id: timer
interval: 60000
repeat: true
running: true
onTriggered:
{
timeText.text = Qt.formatTime(new Date(),"hh:mm")
}
}
source
share