QtObject QML Type
Un tipo básico de QML. Más información...
Propiedades
- objectName : string
Descripción detallada
El tipo QtObject es un elemento no visual que solo contiene la propiedad « objectName ».
Puede resultar útil crear un QtObject si necesitas un tipo extremadamente ligero para agrupar un conjunto de propiedades personalizadas:
import QtQuick
Item {
QtObject {
id: attributes
property string name
property int size
property variant attributes
}
Text { text: attributes.name }
}También puede resultar útil para la integración con C++, ya que se trata simplemente de un ` QObject` sin más. Consulta la documentación de ` QObject ` para obtener más detalles.
Documentación sobre propiedades
objectName : string
Esta propiedad contiene el « QObject::objectName » de esta instancia concreta del objeto.
Esto permite a una aplicación en C++ localizar un elemento dentro de un componente QML utilizando el método ` QObject::findChild()`. Por ejemplo, la siguiente aplicación en C++ localiza el elemento secundario ` Rectangle ` y cambia dinámicamente su valor ` color `:
// MyRect.qml
import QtQuick 2.0
Item {
width: 200; height: 200
Rectangle {
anchors.fill: parent
color: "red"
objectName: "myRect"
}
}// main.cpp
QQuickView view;
view.setSource(QUrl::fromLocalFile("MyRect.qml"));
view.show();
QQuickItem *item = view.rootObject()->findChild<QQuickItem*>("myRect");
if (item)
item->setProperty("color", QColor(Qt::yellow));© 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.