Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to implement Lazy Loading in QTreeView (QTableView) or something similar (model with 100k items)
Qt 6.11 is out! See what's new in the release blog

How to implement Lazy Loading in QTreeView (QTableView) or something similar (model with 100k items)

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 7.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • michalosM Offline
    michalosM Offline
    michalos
    wrote on last edited by
    #1

    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..

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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-loading

      There is also a official sample.
      http://doc.qt.io/qt-5/qtwidgets-itemviews-fetchmore-example.html

      1 Reply Last reply
      3
      • michalosM Offline
        michalosM Offline
        michalos
        wrote on last edited by michalos
        #3

        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.

        michalosM 1 Reply Last reply
        1
        • michalosM michalos

          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.

          michalosM Offline
          michalosM Offline
          michalos
          wrote on last edited by michalos
          #4

          @michalos
          this is my window with the QTreeView (my previous conception was a bit different, thats why it's a treeView, not a QTableView.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved