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. [SOLVED] Qt model alternative?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Qt model alternative?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k Views 1 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.
  • K Offline
    K Offline
    Kobid
    wrote on last edited by
    #1

    Hi,

    I'm old Delphi/FreePascal/Lazarus programmer. I'm programming in Qt and C++ from a year. The most painfull for me in Qt is model programming. Especially efficient. For example filling QStandardItemModel with 1 million records take ~15 seconds, 700MB memory usage and QTreeView scrolling is almost impossible (100% CPU, seems that each scroll validate even not visible items). For comparison, in Lazarus I have TVirtualTreeView where I override one virtual method OnGetData. In arguments I get row and column index and returning data from TList (something like QList) or from dynamic array. Result: filling 1 million records = 150 ms, +20MB in RAM, fully responsible scrolling (OnGetData is called only for visible items). I tried also with QAbstractItemModel, a lot of coding and I only reduced memory usage (not so much).
    My question: Is there any alternative for model programming? Few months ago I saw tutorial for custom dataset in QTreeView but can't find it now. They used simple QList and override few methods in QTreeView.

    Regards

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kobid
      wrote on last edited by
      #2

      Ok I rewrote my model carefully while reading QAbstractItemModel documentation. I reduced memory usage a lot but still had lags while scrolling 1 million records. I changed QTreeView to QListView / QTableView and everything worked very fast. So I checked QTreeView properties and disabled itemsExpandable and checked uniformRowHeights. Finally my view is fast and furious :) . Loading 1 mln record = 1 second, +140MB in RAM, smooth scrolling without lags. Thanks!

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Nice improvements !

        Can you share the technique used model side ? :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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