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] QListView performance issue when model has many items
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QListView performance issue when model has many items

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.4k 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.
  • A Offline
    A Offline
    ainvi
    wrote on last edited by
    #1

    Say, I have an application with QListView, and the respective model stores about 10'000 items in QVector (not that it matters). I don't mind a slight freeze that happens when I update model with all these at once at startup, but I am seriously worried by the fact that GUI freezes every time I add or remove an item. Even removal of a single item causes the whole application to stop responding for some time (it's less than 0.5 seconds, but still irritating).

    There is the following solution, though: set view's layout mode to batched:
    @ui->listView->setLayoutMode (QListView::Batched);@

    However, it will cause the view itself and its scrollbar to blink and flicker every time there's a change.

    Any possible ways to fix this behaviour? I want to mask the fact that QListView takes time to redraw its contents after the model's contents have changed, but I'd still like to have it updating at least every second or so.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      poorBob
      wrote on last edited by
      #2

      Hello, maybe You should try to run the model manipulation in some background thread? In this case You can show the "busy" dialog to the user while the thread is working?

      best regards,
      poorBob

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ainvi
        wrote on last edited by
        #3

        Yeah, that'd sort everything out if it hadn't been a core part of the interface, which is supposed to be always up to date. If you need details, it's a channel's userlist for an IRC client, and I'd have no problems updating it if the channels didn't have that many users. Unfortunately, they do, and people tend to join and part every second.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ainvi
          wrote on last edited by
          #4

          I solved the problem by adding this:
          @ui->listView->setUniformItemSizes(true);@

          into my code. Worked like a charm.

          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