Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Is it possible to use QML ListView as "pagination"
Wiru last edited by
Is there a way to handle large amount of data with a
ListViewto reduce server load? Generally speaking, something like a pagination, but not the standard type where user selects Page 1, 2 ,3... but rather request data while scrolling.
I know that when using a ListView items not in screen are not rendered, so that part is fine, but the issue is when requesting data from
api. If I have a large data set, it takes some time to load it all and create the delegate for the ListView. So the general idea would be to use
offseton the api call, to request data only for the first x items, and if user scrolls, fetch data for the next x items.
Since I can't count on
currentIndex(because the user can scroll the list without selecting/changing the current item) I can't use it to calculate
I know the total count of items in the list, so I could try to limit the ListView model to e.g. 20 items, and when the user scrolls to the end, request next 20 items and extend the model (if that's possible).
All in all, I was hoping for some suggestions and feedback on the idea, or if anyone had some similar case, how did they handle it?
if you have an AbstractItemModel (c++) as a base for your model, you can/should implement the
fetchMoremethods for a dynamic loading of the data.
The this example
for a more detailed view
Wiru last edited by Wiru
ListView. I was also considering in making a custom ListView component based on the ListView class. But if possible, I'd rather not, as it would increase the complexity.
fetchMoredefinitely seems like something that would be great to have. I'll check it out more.
Wiru last edited by
@J-Hilk Quick question regarding
beginInsertRows(), do you by chance know if it resets the ListViws current item/index? It's important for me to keep the selected item intact, e.g. if current index is 5, and it inserts 10 more items, it keeps item at index 5 selected.
I did some research about dynamic ListView models, but in all examples, once the model is extended/updated, ListView resets to index 0, losing users selected item.
I don't know for sure, but I think it simply resets the currentItem/Index
I'm not an expert in the model view field, so maybe someone else can give you a better/more detailed answer
k03rdt6 last edited by k03rdt6
This post is deleted!