[Qt-qml] Accessing delegate instance based on model element

tapani.mikola at nokia.com tapani.mikola at nokia.com
Tue Aug 31 09:42:54 CEST 2010


On 08/31/2010 03:44 AM, ext Alex wrote:

Hi all,

I am instantiating a bunch of components inside a Repeater, based on a
ListModel.  In some cases, I need to act (e.g., invoke a javascript
function)  directly on the delegate of a particular model element.  Is
there a way to access the delegate instance which corresponds to a
particular model element?

Cheers,
Alex
_______________________________________________
Qt-qml mailing list
Qt-qml at trolltech.com<mailto:Qt-qml at trolltech.com>
http://lists.trolltech.com/mailman/listinfo/qt-qml

If you have something like:
Item {
  id: item
  Repeater {
     model: myListModel
....
  }
}

you should be able to do:

item.children[index-to-the-delegate-you-want-to-access].property-you-want-to-access

It seems that the one child created from the Repeater itself (containing e.g. the 'count' property) is always the last child. Not sure, if this is an 'API' that we can count on :)

- Tapani

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100831/b8d39c6e/attachment.html 


More information about the Qt-qml mailing list