rect QML Value Type
x、y、width、height 属性を持つ値。詳細...
| Import Statement: | import QtQml |
詳細な説明
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, 幅 × 高さ」という形式の文字列として指定します:
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の値型」も参照してください 。
© 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.