En esta página

size QML Value Type

un valor con atributos de anchura y altura. Más...

Descripción detallada

El tipo size se refiere a un valor con atributos width y height.

Las propiedades de tipo size tienen Qt.size(-1, -1) como valor por defecto.

Por ejemplo, para leer los valores width y height de la propiedad de tipo tamaño Image::sourceSize:

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

Para crear un valor size, especifíquelo como una cadena "anchura x altura":

Image { sourceSize: "150x50" }

O utilice la función Qt.size():

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

Al realizar la integración con C++, tenga en cuenta que cualquier valor QSize o QSizeF que se pase a QML desde C++ se convierte automáticamente en un valor size, y viceversa. Cuando se pasa un valor size a C++, se convierte automáticamente en un valor QSizeF.

Véase también Tipos de valor 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.