How can I improving performance when I use QListView with large numbers of items
-
Hm ok that looks simple enough. Only small optimization I'd suggest is for DisplayRole:
const auto &item = m_LogList.at(index.row()); return item.LogTime.toString("yyyy.MM.dd hh:mm") + item.LogDesp;
to avoid traversing the list twice. But I don't know any implementation details here, so it is mostly a guess.
Does m_LogList perform any heavy calculations, or complex data reads (SQL or something), or is it just a static list?
-
hi @Mihan
I had the case where I had a very fancy delegate for my ListView, that slowed things down dramatically when one would scroll very quickly.
If that's the bottleneck for you as well, then you could do the same as me.
Replace the delegate with a Loader, set it to asynchronous = true, and only active, if its on screen or the next/previous one in line.
An other fancy Idea I had for that, would be to replace the ListView with a PathView (it circles around) and simply change the data accordingly. Needs a separated index management but should speed things up quickly.
Reading through @sierdzio 's list. Seems like I reinvented the wheel as the batched layout mode is basically that ...
And I'm talking about QML here.
Oh man, I'm not on game today. Need more coffee! -
@J.Hilk Oh wait,I also have a question about QML!
Can I Use QML and UI at the sane time?
Uh....like that I want to replace the SpinBox with Spinner ,the Spinner is on the example-Threading.@Mihan
you can combine qml and Widgets yes.The classes QQuickWidget and QQuickView are specifically made for that purpose.
Atm, to my knowledge, there's no official way to create embeded QWidgets into QML.
So only QML components in QWidgets
-
Hm ok that looks simple enough. Only small optimization I'd suggest is for DisplayRole:
const auto &item = m_LogList.at(index.row()); return item.LogTime.toString("yyyy.MM.dd hh:mm") + item.LogDesp;
to avoid traversing the list twice. But I don't know any implementation details here, so it is mostly a guess.
Does m_LogList perform any heavy calculations, or complex data reads (SQL or something), or is it just a static list?
-
@Mihan
you can combine qml and Widgets yes.The classes QQuickWidget and QQuickView are specifically made for that purpose.
Atm, to my knowledge, there's no official way to create embeded QWidgets into QML.
So only QML components in QWidgets
-
@J.Hilk said in How can I improving performance when I use QListView with large numbers of items:
Atm, to my knowledge, there's no official way to create embeded QWidgets into QML.
There's KDAB's DeclarativeWidgets which might be of some help.
-
@J.Hilk said in How can I improving performance when I use QListView with large numbers of items:
Atm, to my knowledge, there's no official way to create embeded QWidgets into QML.
There's KDAB's DeclarativeWidgets which might be of some help.
@SGaist Hi SGaist
I found the Listview showed nothing few second if the layoutmode is batched.So I want to add a loading gif to make it .......Uh, you know that? Like the reflash of web and so on. But I can't find some signals or event about update, just it has a updatelater event when i used eventfiler to show all events. Could you give me a hand?
Thank you so much! -
How many items are you loading ?
-
Depending on what you are going to do with these items, you will likely need to implement things like windowing to avoid having uselessly too many items in memory.