rect QML Basic Type

A rect type has x, y, width and height attributes.

A rect 类型拥有 x , y , width and height 属性。

For example, to read the Item::childrenRect rect 特性:

Rectangle {
    width: childrenRect.width
    height: childrenRect.height
    Rectangle { width: 100; height: 100 }
}
					

要创建 rect value, specify it as a "x, y, width x height" string:

CustomObject { myRectProperty: "50,50,100x100" }
					

Or use the Qt.rect() function:

CustomObject { myRectProperty: Qt.rect(50, 50, 100, 100) }
					

另请参阅 QML 基本类型 .