[SOLVED] QListView performance issue when model has many items
-
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.
-
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 -
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.
-
I solved the problem by adding this:
@ui->listView->setUniformItemSizes(true);@into my code. Worked like a charm.