- 自定义QML组件
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
import QtQuick.Controls 1.4 as Ctr1
import QtQuick.Layouts 1.2
import './Text.js' as Jie
Window{
id:window
width:640
height:480
visible: true
title:"Hello world"
Item{
id:jieItem
anchors.fill:parent
property var colorBuilder:Jie.getColorFactory(Qt.rgba)
Component{
id:dateTimeLabel
JieDateTimeLabel{
text:"Jie Data Time Label"
}
}
Column{
Component.onCompleted: {
dateTimeLabel.createObject(this)
dateTimeLabel.createObject(this)
dateTimeLabel.createObject(this)
dateTimeLabel.createObject(this)
}
}
}
}
import QtQuick 2.12
import QtQuick.Controls 2.5
Label{
Timer{
interval: 1000
repeat: true
running: true
triggeredOnStart: true
onTriggered: {
parent.setDate(Qt.formatDateTime(new Date(),'yyyy-MM-dd hh:mm:ss'))
}
}
font.bold: true
font.italic: true
color: 'black'
function setDate(dateString){
text = dateString
}
}
