ListView is (very) slow to move to current item
-
ListView will move the highlight from its current position to the new current item, scrolling the view as it moves. If your model is slow to provide data or you have a complex delegate then it will struggle to scroll smoothly. The best solution is to move the view directly to the target index and then set the currentIndex, e.g.
@
idLV.positionViewAtIndex(nci, ListView.Visible)
idLV.currentIndex = nci
@ -
MartinJ, positionViewAtIndex also will evaluate height for all elements from current to nci.
-
I'm agree with Alexander, the height of intermediary item is evaluated in this situation also. I think the solution it's a particular API (at least one method) to set the height of item in a listview.
-
I find it a bit weird that we run into this issue again. It in the widgets world, the need for this feature for optimization purposes was already known. QListView has it, for instance. QML should not be about reinventing the wheel, should it?
-
Andre, where is it in QListView? QListView also evaluates height for all elements.
-
[quote author="Alexander Kuchumov" date="1292868441"]Andre, where is it in QListView? QListView also evaluates height for all elements.[/quote]
It is right "here":http://doc.qt.nokia.com/4.6/qlistview.html#uniformItemSizes-prop. You can tell QListView that the items are all the same size, and then it only evaluates the hight of the first item. -
Andre, I've missed this function:)
-
Don't :-) It can make a huge difference in QListViews performance.
-
positionViewAtIndex() does not calculate the height of intermediary items. That is the point of that function.
-
MartinJ is right, positionViewAtIndex uses averageSize .
-
How is averageSize calculated? It is not a property of the ListView element, so where does it come from?
-
Andre, averageSize is calculated for last visible elements.
-
OK, that makes sense I guess.
-
Hi, I have a problem similar to yours. I have a ListView with possibly thousands of elements. I keep a property in my PySide backend which is the currentIndex for my ListView. Whenever I change the index, the ListView should scroll to the current item.
It works, but the scrolling is very slow. I think it is the same problem you are describing. Do you have any idea how should I solve my case?
-
Anybody has a suggestion? I have the same problem on my arm 300 mhz device... I also want to drop the scroll animation and just jump immediately to the next item.