1

I'm coming from iOS development where the basic UITableView and UIScrollView containers cache and then recycle table cells, loading only what will be visible as the user scrolls, in order to conserve memory and improve performance.

I've been trying to find out if the QListView, QTreeView, etc. containers work this way or if they load the entire data source irregardless of what subsection of it will actually be displayed.

I'm not having any issues yet but I am working with an SQLite db with potentially thousands of records, and the QListView will be displaying a thumbnail along with text for each record. So far testing with a few hundred records performance is good but I am wondering if the Qt Model/View approach scales well or if I need to think about managing this myself.

spring
  • 18,009
  • 15
  • 80
  • 160
  • 1
    See http://stackoverflow.com/questions/2857008/qtreeview-memory-consumption for memory analysis of `QTreeView`, `QListView` and `QTableView`. Their conclusion: `QTableView` should be used with very large datasets. – Nathan Jan 27 '14 at 14:53

2 Answers2

2

All Qt widgets load all data at once but they are painted only when visible. There is no straight note about this but you can check it by yourself. Try to create for e.g. list with 50 items and then with 50 000 items. You'll see the difference.

What i can say from my experience, over 1000 items in widget may cause some delays in painting and repainting widget, but not when scrolling. If you will just load items and they will be static, i think you shouldn't bother this thing. In other case you should use setItemDelegateForRow() to control number of painted rows.

Blood
  • 4,126
  • 3
  • 27
  • 37
0

In General Model/View architecture, Model doesn't know , how many cells need to display on view. View knows very well, how many row/columns are visble at a particular time. So In Qt for QListView, It will call "QAbstractItemModel::data ( index, Qt::DisplayRole )", with appropriate index, to displaying item.. So It load only what will be visible on QListView. However you must emit "dataChanged()" from model whenever any particular cell is get updated. so view can call corresponding slot to update the visible area with the help of Model's "QAbstractItemModel::data". The answer is yes, you can very well use Qt.

Another approach is using QGraphicsView Framework, It does same, QGraphicsItems are updated only for visible scene area. But you need to call"setPos()" for laying out items explicitly.

Ashif
  • 1,652
  • 14
  • 30