Unsolved How to implement Lazy Loading in QTreeView (QTableView) or something similar (model with 100k items)
-
Hi,
Does any one know how to implement lazy loading with QTreeView? Or how to implement something like QListView::setLayoutMode(QListView::Batched)?
I have a treeView with over 100k items and dragging the vertical scrollbar makes the aplication freeze.
(Or maybe there is something like that for QTableView? It would be possible to switch to a tableView)
Have any one dealt with such problem before?
Google is silent in this matter.. -
Hi
As far as I know, you can do that via a custom model overriding QAbstractItemModel::canFetchMore()
and QAbstractItemModel::fetchMore() for your model.
see here
http://www.qtcentre.org/threads/62245-Need-to-show-SQL-data-in-tree-view-with-lazy-loadingThere is also a official sample.
http://doc.qt.io/qt-5/qtwidgets-itemviews-fetchmore-example.html -
I have tried the example on a folder with almost 11000 elements (folder with icons and links to those icons), and all it does is to fetch more data, when I scroll through the list, but still slowing down.
I think that my subclassed QTreeView does the same, but witch the example, the scrollbar doesn't represent the actual size of the list, and in my app it does.
Also, I think that (I don't know how, but) my view is being drawn faster, than the example.
Is there a way, to draw in the View only what is visable? I mean that when an Item leaves the View, I don't want it to be drawn, because the model will be updated quite often. -