rect QML Value Type
一个带有 x、y、宽度和高度属性的值。更多
详细说明
rect
类型指的是带有x
、y
、width
和height
属性的值。
rect
类型的属性默认为Qt.rect(0, 0, 0, 0)
。这是一个位于坐标原点的空矩形。
例如,要读取Item childrenRect 矩形类型属性的width
和height
值:
Rectangle { width: childrenRect.width height: childrenRect.height Rectangle { width: 100; height: 100 } }
要创建rect
值,请将其指定为 "x, y, width x height "字符串:
CustomObject { myRectProperty: "50,50,100x100" }
或使用Qt.rect() 函数:
CustomObject { myRectProperty: Qt.rect(50, 50, 100, 100) }
rect
类型还公开了只读的left
,right
,top
和bottom
属性。这些属性与C++ counterparts 相同。
与 C++ 集成时,请注意从 C++ 传入 QML 的任何QRect 或QRectF 值都会自动转换为rect
值,反之亦然。当rect
值传入 C++ 时,会自动转换成QRectF 值。
另请参阅 QML 值类型。
© 2025 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.