このページでは

size QML Value Type

width および height 属性を持つ値。詳細...

Import Statement: import QtQml

詳細な説明

size 型は、width およびheight 属性を持つ値を指します。

size 型のプロパティは、Qt.size(-1, -1) をデフォルト値として持ちます。

たとえば、Image::sourceSize の size-type プロパティのwidth およびheight の値を読み取るには、次のようにします。

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

size 値を作成するには、「幅 × 高さ」の形式の文字列として指定します:

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.