Hello
I have set up a QAbstractListModel together with a QStyledItemDelegate and QListView.
In the model i have a method called "populate" which will search the local disk for some data, and then append it to the data list in the model via a signal. The signal invokes layoutChanged() (don't know how to use dataChanged anywhere except in the obligatory data method), which will then refresh the layout with the new data. (This happens only once)
The QStyledItemDelegate draws the items on the QListView in iconMode gridview.
Everything is working except the QListView being unresponsive, lagging, flicks and won't allow me to scroll for a long time.
The messages i get in the console are:
QBuffer::seek: Invalid pos: -345244657
QBuffer::seek: Invalid pos: -345244657
- multiple times everytime i move my mouse in the QListView.
I did some research before writing this, but couldn't find anything useful.
I suspect this being the main reason on why the QListView is so unresponsive, and i think it's something related to the QIcon i make.
However i did some profiling and saw that the paint method in the Delegate got called over 200 times in an elapsed time of 1 minute without me touching the mouse.
My code:
http://pastebin.com/gjKJwJuU
Things to note:
I use PyQt5 but can understand slight C++ code.
Pseudo code will only be useful for me if you include the methods being called.
Edit #1:
I just realized that with the fetchMore method, I don't need to emit layoutChanged so i removed that.
I also moved the endResetModel() call up to the append method, because that's when items are actually added into the model.
This changed nothing. ListView is still being unresposive/lagging. I also tried only adding 3-5 items to the list still getting same results...
Edit #2:
Okay so i stopped the paint method in the delegate from painting the images, which seems to have fixed the laggy QListView...
I also stopped getting the QBuffer::seek invalid pos: -xxxxxx messages.
So now i have another question.
How do i fix the lagging in the QListView when painting images?
I'm changing the title to this question instead of: QBuffer::seek invalid pos: -xxxxxx.
Bookmarks