ListModel and item
-
My situation is a ListModel and some objects in it:
ScrollView { id: scrollView1 ListView { id: listView; model: listViewModel; delegate: listViewDelegate; } } Component { id: listViewDelegate; QQShareObject { } } ListModel { id: listViewModel; }
How can I call a function into QQShareObject objects?
I tried
listViewModel.get(0).internalFunction()
but does not work..
I need to have the current value of my QQShareObject object. -
Hi,
@mrdebugTry this
listView.currentIndex = 6 // or whatever console.log(listView.currentItem) // gives the item at 6th position
You can then access its properties. For eg:
listView.currentItem.myId
-
This post is deleted! -
for (var count= 0; count< listView.count; count++) {
listView.currentIndex= count
console.log(listView.currentItem.getValue())
}is not a good solution. The line
listView.currentIndex= count
changes the current selected item.
Is possible to have the value of each items without to change the item index? -
@mrdebug then the other way to access delegate would be to use
children
For eg:view.contentItem.children[2].myId
view
=id
ofListView
andmyId
is declared asQ_PROPERTY
inQQShareObject
-
Perfect!