Solved QML ListView: Load data portion. How?
-
Hello all!
Is in ListView any option to load into ListModel data by portions? For example I have 2000 rows in DB, but on device in one screen without scrolling only 10 and a few in memory because of chacheBuffer. In following of documentation whole amount of data should be in LitModel? Am I right? Is the option to load into ListView model data portion by portion?
If ListView has no any data handlers for loading portion-by-portion, which QML Component will be OK with this issue?
-
for partial loading data one is supposed to use
https://doc.qt.io/qt-5/qabstractitemmodel.html#canFetchMore
and
https://doc.qt.io/qt-5/qabstractitemmodel.html#fetchMore -
@J-Hilk Am I right - I need to develop my own "ListModelImplementation" based on QAbstractItemModel and attach it to ListView?
-
@bogong yes, those functions are pure virtual and you need to provide/override them, when you create your "ListModelImplementation"
-
@J-Hilk Is there example of it?
-
@bogong https://doc.qt.io/qt-5/qtwidgets-itemviews-fetchmore-example.html
doesn't matter if the view is QWidget or QML, the model should work for both -
@J-Hilk Thx a lot.