set index of ListView from Delegate
-
Hi all -
I'm trying to make a list of items clickable. When an item is clicked, the index of the list should be updated. Here's what I've got so far:
ActivityModel { // from c++ id: activityModel } Component { id: activityDelegate Activitybar { id: activityElement } } ListView { id: activityView model: activityModel delegate: activityDelegate } // Activitybar.qml Rectangle { id: activityBar MouseArea { anchors.fill: parent onClicked: { // how can I set the list index here? } } }
Do I need an explicit property to hold the index in my Delegate? And if so, what's the syntax for the assignment?
Thanks...
-
@mzimmers said in set index of ListView from Delegate:
activityBar
activityBar is the delegate and there is an index for each delegate
onClicked: {
console.log( index )
}