124 lines
3.0 KiB
QML
124 lines
3.0 KiB
QML
import QtQuick
|
|
|
|
Window {
|
|
width: 640
|
|
height: 480
|
|
visible: true
|
|
title: qsTr("QML Datatypes Demo")
|
|
|
|
property string mString: "https://www.learnqt.guide"
|
|
|
|
property int mInt: 45
|
|
|
|
property bool isFemale: true
|
|
|
|
property double mDouble: 77.5
|
|
|
|
property url mUrl: "https://www.learnqt.guide"
|
|
|
|
property var aNumbre: 100
|
|
property var aBool: false
|
|
property var aString: "Hello world!"
|
|
property var anotherString: String("#FF008800")
|
|
property var aColor: Qt.rgba(0.2, 0.3, 0.4, 0.5)
|
|
property var aRect: Qt.rect(10, 10, 10, 10)
|
|
property var aPoint: Qt.point(10, 10)
|
|
property var aSize: Qt.size(10, 10)
|
|
property var aVector3d: Qt.vector3d(100, 100, 1000)
|
|
property var anArray: [1, 2, 3, "four", "five", (function(){return "six";})]
|
|
property var anObject: {"foo": 10, "bar": 20}
|
|
property var aFunction: (function() {return "one"})
|
|
|
|
property var aFont: Qt.font({family: "Consolas", pointSize: 30, bold: false})
|
|
property date mDate: "2018-07-19"
|
|
|
|
property var fonts: Qt.fontFamilies()
|
|
|
|
// Row {
|
|
// anchors.centerIn: parent
|
|
Rectangle {
|
|
id: yellowRectId
|
|
x: 300
|
|
width: 200
|
|
height: 100 + mInt
|
|
|
|
color: "yellow"
|
|
|
|
Text {
|
|
id: mTextId
|
|
font: aFont
|
|
anchors.centerIn: parent
|
|
text: mString
|
|
// font.bold: isFemale ? true : false
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.left: yellowRectId.right
|
|
width: 200
|
|
height: width * 1.5
|
|
color: aColor
|
|
|
|
}
|
|
// }
|
|
|
|
|
|
Rectangle {
|
|
id: blueRectId
|
|
color: "blue"
|
|
width: 100
|
|
height: 100
|
|
anchors.bottom: parent.bottom
|
|
anchors.right: yellowRectId.left
|
|
// anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: {
|
|
// yellowRectId.height = yellowRectId.height + 10
|
|
yellowRectId.height = Qt.binding(function() {
|
|
return yellowRectId.width + 10
|
|
})
|
|
|
|
for (var i = 0; i < fonts.length; i++) {
|
|
console.log("["+i+"]:" + fonts[i])
|
|
}
|
|
|
|
console.log(Qt.md5("123456"))
|
|
console.log("Quitting the App")
|
|
Qt.quit()
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
Component.onCompleted: {
|
|
if (mString === mUrl)
|
|
{
|
|
console.log("They are the same")
|
|
}else{
|
|
console.log("They are NOT the same")
|
|
}
|
|
|
|
if (isFemale) {
|
|
console.log("You may wear a dress")
|
|
}
|
|
else {
|
|
console.log("You may wear a suit")
|
|
}
|
|
|
|
console.log("The value of mInt is :"+mInt)
|
|
|
|
for(var i = 0; i < anArray.length; i++) {
|
|
if (i===5) {
|
|
console.log(anArray[i]())
|
|
}
|
|
else {
|
|
console.log(anArray[i])
|
|
}
|
|
}
|
|
|
|
console.log("The date is: " + mDate)
|
|
}
|
|
}
|