In questa pagina

size QML Value Type

un valore con gli attributi "width" e "height". Altro...

Import Statement: import QtQml

Descrizione dettagliata

Il tipo size si riferisce a un valore dotato degli attributi width e height.

Le proprietà di tipo size hanno come valore predefinito Qt.size(-1, -1).

Ad esempio, per leggere i valori di ` width ` e ` height ` della proprietà di tipo dimensione ` Image::sourceSize `:

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

Per creare un valore size, specificarlo come stringa "larghezza x altezza":

Image { sourceSize: "150x50" }

Oppure utilizzare la funzione Qt.size():

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

Quando si integra con C++, tenere presente che qualsiasi valore di tipo ` QSize ` o ` QSizeF ` passato a QML da C++ viene automaticamente convertito in un valore di tipo ` size ` e viceversa. Quando un valore di tipo ` size ` viene passato a C++, viene automaticamente convertito in un valore di tipo ` QSizeF `.

Vedi anche Tipi di valore 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.