size QML Basic Type

A size type has width and height attributes

A size 类型拥有 width and height 属性。

For example, to read the Image::sourceSize size 特性:

Column {
    Image { id: image; source: "logo.png" }
    Text { text: image.sourceSize.width + "," + image.sourceSize.height }
}
					

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

LayoutItem { preferredSize: "150x50" }
					

Or use the Qt.size() function:

LayoutItem { preferredSize: Qt.size(150, 50) }
					

另请参阅 QML 基本类型 .