Nesta página

size QML Value Type

um valor com os atributos width e height. Mais...

Import Statement: import QtQml

Descrição detalhada

O tipo ` size ` refere-se a um valor que possui os atributos ` width ` e ` height `.

Propriedades do tipo ` size ` têm ` Qt.size(-1, -1) ` como valor padrão.

Por exemplo, para ler os valores de ` width ` e ` height ` da propriedade de tipo de tamanho ` Image::sourceSize `:

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

Para criar um valor de size, especifique-o como uma string do tipo “largura x altura”:

Image { sourceSize: "150x50" }

Ou use a função Qt.size():

Image { sourceSize: Qt.size(150, 50) }

Ao integrar com C++, observe que qualquer valor ` QSize ` ou ` QSizeF ` passado do C++ para o QML é automaticamente convertido em um valor ` size `, e vice-versa. Quando um valor ` size ` é passado para o C++, ele é automaticamente convertido em um valor ` QSizeF `.

Veja também Tipos de valores do 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.