incremental loading without total count information
-
i'm wondering whether it is possible to implement incremental data loading in views without knowing the total number of results in advance?
-
QAbstractbModelhas fundamentalfetchMore(), https://doc.qt.io/qt-5/qabstractitemmodel.html#fetchMore, and for example theQSqlmodels implement this 256 rows at a time. So incremental loading is going on regardless of row count.You can leverage that in your views. "Paging" can fetch the next block of rows.
-
QAbstractbModelhas fundamentalfetchMore(), https://doc.qt.io/qt-5/qabstractitemmodel.html#fetchMore, and for example theQSqlmodels implement this 256 rows at a time. So incremental loading is going on regardless of row count.You can leverage that in your views. "Paging" can fetch the next block of rows.
@JonB
forfetchMore()to work, i need to implementcanFetchMore()which means i need to know whether there's more data available or not?
how willdata()be called for model index, ifrowCount()is not known? -
@JonB
forfetchMore()to work, i need to implementcanFetchMore()which means i need to know whether there's more data available or not?
how willdata()be called for model index, ifrowCount()is not known?@user4592357
You only have to know if there is more data to fetch, not how many total there is. But in any case I assume you can havecanFetchMore()returntruewhile you don't know, and only infetchMore()do you do the next fetch and discover whether there was any more.If a
QModelIndexis for row not yet fetched, you can havedata()fetch more to resolve the reference if necessary. You wouldn't have to know the finalrowCount()up front.