rect QML Value Type
un valore con gli attributi x, y, larghezza e altezza. Altro...
| Import Statement: | import QtQml |
Descrizione dettagliata
Il tipo rect si riferisce a un valore con gli attributi x, y, width e height.
Le proprietà di tipo rect sono Qt.rect(0, 0, 0, 0) per impostazione predefinita. Si tratta di un rettangolo vuoto nell’origine delle coordinate.
Ad esempio, per leggere i valori di width e height della proprietà di tipo rettangolo Item childrenRect :
Rectangle {
width: childrenRect.width
height: childrenRect.height
Rectangle { width: 100; height: 100 }
}Per creare un valore rect, specificarlo come stringa "x, y, larghezza x altezza":
CustomObject { myRectProperty: "50,50,100x100" }Oppure utilizzare la funzione ` Qt.rect()`:
CustomObject { myRectProperty: Qt.rect(50, 50, 100, 100) }Il tipo ` rect ` espone anche gli attributi di sola lettura ` left`, ` right`, ` top ` e ` bottom `. Questi sono identici ai corrispondenti attributi ` C++ counterparts`.
Quando si integra con C++, si noti che qualsiasi valore di tipo ` QRect ` o ` QRectF ` passato a QML da C++ viene automaticamente convertito in un valore di tipo ` rect `, e viceversa. Quando un valore di tipo ` rect ` viene passato a C++, viene automaticamente convertito in un valore di tipo ` QRectF `.
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.