[Qt-qml] Find by id.
René Hansen
ext-rene.1.hansen at nokia.com
Thu Nov 4 13:26:26 CET 2010
I'd like to be able to find child objects in a QML structure and to do
that, I've exposed a new QML Object with qmlRegisterType, which provides
me with:
QObject *QmlUnitTestHelper::getChildById(QObject *parent, QString name) {
return parent->findChild<QObject *>(name);
}
And in Qml I have something like this:
Rectangle {
QmlUnitTestHelper {
id: quth
}
Rectangle {
id:outerRect
Rectangle {
id:innerRect
Text {
id:label
text: "Hello World"
}
}
}
}
Which should enable me to test in something like this manner:
quth.getChildById(outerRect, "innerRect").label.text == "Hello World"
However, this doesn't work as expected, so I guess my assuming the QML
id property being the same as a QObjects objectName is faulty.
How would I go about doing something like this?
/René
More information about the Qt-qml
mailing list