Can the QDeclarativeEngineDebug be used in test code and in the tools somehow for this?
-P >-----Original Message----- >From: qt-qml-boun...@trolltech.com [mailto:qt-qml-boun...@trolltech.com] >On Behalf Of Alpert Alan (Nokia-MS-Qt/Brisbane) >Sent: 05.11.2010 09:18 >To: qt-qml@trolltech.com >Subject: Re: [Qt-qml] Getting the id > >On Fri, 5 Nov 2010 16:59:00 Lahtela Tuukka.M (EXT-Tieto/Tampere) wrote: >> Hi! >> >> This is somewhat related to the “Find by id” thread. Is it somehow >possible >> to get id of the of a qml element. It would be useful for our >automated >> testing tool. >> >> Rectangle { >> id: myRect >> objectName: "theRectangle" >> } >> >> So basically I would need to get the id of the element in c++ code >(for >> example the myRect value in the example qml). I do not seem to find >a >> way to do this. >> >> >> * Tuukka Lahtela > >It is not possible. > >id only exists in QML and it does not map cleanly to C++ instances. >Consider >the following example: > >Item{ > id: a > Repeater{ > id: repeater > model: 5 > delegate: Item{ > id: delRoot > Text{ > id: delText > text: index; anchors.fill: delRoot; > } > } > } >} > >In the QML file there are four elements with their own ids. When >instantiated, >you have eight items, including five instances of the item described by >delRoot. > >There are also cases where one C++ instance may have multiple ids >through >being used in multiple files. > >For testing purposes, consider setting the objectName property and using >that. >Also be aware of the existing automated testing options that Michael >mentioned >in the find by id thread. As those test frameworks work inside QML, I >believe >that you can access elements by id in your tests. > >-- >Alan Alpert >Software Engineer >Nokia, Qt Development Frameworks > >_______________________________________________ >Qt-qml mailing list >Qt-qml@trolltech.com >http://lists.trolltech.com/mailman/listinfo/qt-qml _______________________________________________ Qt-qml mailing list Qt-qml@trolltech.com http://lists.trolltech.com/mailman/listinfo/qt-qml