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

Alex alexlordax+qt at gmail.com
Tue Aug 31 19:40:42 CEST 2010


On Tue, Aug 31, 2010 at 12:42 AM,  <tapani.mikola at nokia.com> wrote:
> 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
> 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
>

Thanks, Tapani and Gregory.  I was expecting to find these as children
of the Repeater, but reparenting to the parent of the Repeater makes
sense.

Cheers,
Alex




More information about the Qt-qml mailing list