size QML Value Type
具有 width 和 height 属性的值。更多...
| Import Statement: | import QtQml |
详细说明
size 类型指具有width 和height 属性的值。
size 类型的属性默认值为Qt.size(-1, -1) 。
例如,要读取 `Image::sourceSize ` 大小类型属性的 `width ` 和 `height ` 值:
Column {
Image { id: image; source: "logo.png" }
Text { text: image.sourceSize.width + "," + image.sourceSize.height }
}要创建一个 `size ` 值,请将其指定为“宽度 x 高度”格式的字符串:
Image { sourceSize: "150x50" }或者使用Qt.size() 函数:
Image { sourceSize: Qt.size(150, 50) }在与 C++ 集成时,请注意:从 C++ 传递到 QML 的任何QSize 或QSizeF 值都会自动转换为size 值,反之亦然。当size 值传递给 C++ 时,它会自动转换为QSizeF 值。
另请参阅 QML 值类型。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.