size 是QML 的一個基礎類型,具有 width 和 height 屬性。
可以用於表示圖片,窗體的尺寸。
使用 size。見examples
import QtQuick 2.0
Rectangle { // 基本類型,生成一個矩形
width: 360 //矩形寬
height: 360 //矩形高
color: "lightblue" //矩形內部顏色
//定義 size, 這個size 可以被其他的element調用,並對size 複製,進而創建不同尺寸的rect
property size leftWindowSize: Qt.size(120, 120)
property size rightWindowSize: Qt.size(80, 80)
Rectangle {
x: 0
y: 120
width: leftWindowSize.width
height: leftWindowSize.height
color: "black"
}
Rectangle {
x: 140
y: 140
width: rightWindowSize.width
height: rightWindowSize.height
color: "black"
border.color: "red"
border.width: 10
}
MouseArea { //鼠標有效區域
anchors.fill: parent // 有效區域爲矩形區域(也就是他的父對象
onClicked: { //響應鼠標點擊
Qt.quit()
}
}
}