On Tue, Aug 31, 2010 at 2:40 PM, Alex <[email protected]> wrote:
> On Tue, Aug 31, 2010 at 12:42 AM, <[email protected]> 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
>> you should be able to do:
>>
>> item.children[index-to-the-delegate-you-want-to-access].property-you-want-to-access
>>
Hi,
Instead of accessing the delegate directly, it's better to change it
through Model/View mechanism, using property bindings like below:
Item {
width: 400
height: 400
ListModel {
id: model
ListElement { color: "red" }
ListElement { color: "green" }
ListElement { color: "blue" }
}
Column {
Repeater {
model: model
Rectangle {
id: item
width: 50
height: 50
color: model.color
}
}
}
MouseArea {
anchors.fill: parent
onClicked: model.setProperty(1, "color", "gray");
}
}
Does it solve your problem?
Br,
Adriano
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml