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é



_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to