ListView: Use positionItemAtIndex when some items are invisible
-
Hi,
I have a listview and a model. The model has some roles, which determine if a delegate should be shown, and I set the visible property of the delegate according to those roles. On clicked I want to use positionViewAtIndex to move the clicked item to the center of the list, but this is giving me some problems (empty lines before and after that item). I might not fully understand which index positionViewAtIndex wants. The actual index in the listview of visible items or the model index.
The dummy code looks like this
delegate: Item { onSpecialRoleChanged: { positionViewAtIndex(model.index) } }
Maybe its also a bad idea to call this function inside the delegate.
Btw, is there an easy way to get the visual index of an item in a listview (not the model index, as those things differ if we have invisible items)
Thanks!