QAbstractTableModel data preloading
-
Hi,
I'm trying to show large data set in QTableView. Now, I want to preload the data for the all visible rows, instead of reading the data row by row. I've searched the docs but couldn't find the function/signal which could be used. Is something like this possible with QAbstractTableModel or do I need to make the custom QTableView?Thanks
-
Hi
There is FetchMore
https://doc.qt.io/qt-5/qtwidgets-itemviews-fetchmore-example.html -
@Trigve
Hi
Well the view call canFetchMore() when it needs more data
so not sure you need to manually care about what is visible or not.
As far as I know, if you implement
https://doc.qt.io/qt-5/qabstractitemmodel.html#canFetchMore
and
https://doc.qt.io/qt-5/qabstractitemmodel.html#fetchMoreThen it just works :)
-
@mrjj
But how do I know how many rows do I need to preload? In the link you posted, the items are loaded in 100 increments. So I may do the same, but this could be ineffective because instead of 1 preload of the all the data I need, I would make 2-3 depending of the height of the view.Anyway, thanks for the help.
-
@Trigve
Well You could use
https://doc.qt.io/qt-5/qabstractitemview.html#visualRect
to check if they are shown if you want to optimize that much.
Im not sure how to easy check how many lines visible but
but if you are using fixed row height then its easy to calc with
viewport height and item height.