rect QML Value Type

x, y, width, height属性を持つ値。詳細...

詳細説明

rect 型は、xywidthheight 属性を持つ値を指します。

rect 型のプロパティは、デフォルトではQt.rect(0, 0, 0, 0) です。これは、座標原点における空の矩形です。

た と えば、Item childrenRect の矩形型プ ロパテ ィ のwidthheight の値を読み取 る 場合:

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に渡された QRectQRectF の値は自動的に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.