QML QtObject ElementThe QtObject element is the most basic element in QML. More... QtObject instantiates the C++ class QObject This element was introduced in Qt 4.7. Properties
Detailed DescriptionThe QtObject element is a non-visual element which contains only the objectName property. It can be useful to create a QtObject if you need an extremely lightweight element to enclose a set of custom properties: import QtQuick 1.0 Item { QtObject { id: attributes property string name property int size property variant attributes } Text { text: attributes.name } } It can also be useful for C++ integration, as it is just a plain QObject. See the QObject documentation for further details. Property DocumentationThis property holds the QObject::objectName for this specific object instance. This allows a C++ application to locate an item within a QML component using the QObject::findChild() method. For example, the following C++ application locates the child Rectangle item and dynamically changes its color value: // MyRect.qml import QtQuick 1.0 Item { width: 200; height: 200 Rectangle { anchors.fill: parent color: "red" objectName: "myRect" } } // main.cpp QDeclarativeView view; view.setSource(QUrl::fromLocalFile("MyRect.qml")); view.show(); QDeclarativeItem *item = view.rootObject()->findChild<QDeclarativeItem*>("myRect"); if (item) item->setProperty("color", QColor(Qt::yellow)); © 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Privacy Policy Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. |