[Interest] QAbstractListModel - huge data model - when to drop data?

Putze Sven mailinglist.Qt-creator at hardcodes.de
Thu Aug 8 14:11:10 CEST 2013


Hi there,

if I use the QAbstractListModel or QAbstractItemModel and present the data via QTableView I can create a new thread (e.g. QThread or QRunnable) to fetch data, that is
a) slow to load
b) huge in size
to prevent the QTableView from stutter that would otherwise occur when the data() method is called. I can even present data that indicates the load process.
If the second (or whatever number) thread has loaded the data, the model is updated, dataChanged is emitted, QTableView asks the now updated data via data() and displays the refreshed data.
So far, so good - that plays nice.

But how can I (or the program) know, that data is scrolled outside the viewport, so that I can
a) cancel loading threads, because the data is not needed anymore or
b) discard loaded data from memory, to reduce the memory footprint?
The latter is not pressing on a desktop maybe (and that just depends on the size of the model or the data stored inside) but on a mobile device it can be crucial.

Mr. Google told me, that some people asked this question before but it didn't show me an answer to this question, so here I go...


Best.
Sven




More information about the Interest mailing list