Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
ListView animation while prefetching
Ayelet Cohen last edited by Ayelet Cohen
I'm trying to create a ListView that the user can scroll infinitely, by fetching more and more data on the background.
The problem is that whenever I add new items to the model, the scrolling animation "jumps" and then continues.
I want to get rid of that glitch.
What I have
I have a vertical ListView which the user can scroll using Up/Down keyboard keys.
Scrolling is done with animation (item X moves to position X+1 with animation) - the standard ListView animation that happens when you set highlightRangeMode: ListView.StrictlyEnforceRange.
The model is written in C++ (inheriting from QAbstractListModel), and is prefetching new data as the view progress through the end of model:
- When data() is called, and the index is close to the end of the model, it goes to the server to bring more items. It appends the new items to the model, but does not report anything to the view, and *rowCount() * also doesn't reflect the new size of the model.
- On *canFetchMore() * it returns true if we have already prefetched items that were added to the model but not reported to the view.
- On fetchMore() it calls beginInsertRows, update the row count to reflect the new items insertion, and calls endInsertRows.
If code is needed to be inspected, let me know.
Thanks a lot!