rect QML Value Type
un valor con los atributos x, y, ancho y alto. Más...
| Import Statement: | import QtQml |
Descripción detallada
El tipo « rect » hace referencia a un valor con los atributos « x », « y », « width » y « height ».
Las propiedades de tipo « rect » son « Qt.rect(0, 0, 0, 0) » por defecto. Se trata de un rectángulo vacío situado en el origen de coordenadas.
Por ejemplo, para leer los valores de « width » y « height » de la propiedad de tipo rect « Item » childrenRect:
Rectangle {
width: childrenRect.width
height: childrenRect.height
Rectangle { width: 100; height: 100 }
}Para crear un valor rect, especifícalo como una cadena «x, y, ancho x alto»:
CustomObject { myRectProperty: "50,50,100x100" }O bien, utiliza la función Qt.rect():
CustomObject { myRectProperty: Qt.rect(50, 50, 100, 100) }El tipo ` rect ` también expone los atributos de solo lectura ` left`, ` right`, ` top ` y ` bottom `. Estos son iguales a sus equivalentes en ` C++ counterparts`.
Al integrar con C++, ten en cuenta que cualquier valor de tipo « QRect » o « QRectF » pasado a QML desde C++ se convierte automáticamente en un valor de tipo « rect », y viceversa. Cuando se pasa un valor de tipo « rect » a C++, se convierte automáticamente en un valor de tipo « QRectF ».
Véase también Tipos de valores de 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.