实时时间的显示也比较简单,我们先来看显示效果:
代码也超级简单,这里代码贴上就行了,不懂的自行研究哈。
import QtQuick 2.15
import QtQuick.Controls 2.15
import DigitalCluster 1.0
Item {
id:time
width:62;height: 46
property var currentDate:new Date()
property string currentTime:currentDate.getHours() + ":" + currentDate.getMinutes()
Rectangle{
anchors.fill:parent
color: "black"
}
Text{
id:timeValue
x:0;y:0
width:62;height: 29
color:Themes.textColor
text:time.currentTime
font.pixelSize: 24
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignTop
wrapMode: Text.Wrap
font.weight: Font.Normal
font.family: Constants.font.family
}
Text{
id:timeLabel
x:0;y:2