QListView does not update when underlying data changes
-
I am working on a custom view (currently QListView) that is supposed to use icons instead of text.
The icons are loaded in another thread, the items in the view shall be updated accordingly (and asynchronously).
BUT: The icons don't show up, the view isn't updated, the delegates paint()-function is only called once when I launch the program and rarely (and seemingly randomly) after that.As far as I know, changing the contents (i.e. the text) of e.g. a QStandardItem in a QStandardItemModel visualized by some view (with a QSortFilterProxyModel in between) does update the view immediately.
How can I make the view update whenever the data of the underlying model changes? -
Hi,
By triggering the appropriate signal at the right time from the model to notify the view that something is happening. Essentially emit dataChanged from your model.
-
When the data in the source model is changed, the proxy model knows about it (without me needing to emit the signal manually). How does that happen and why doesn't the view make use of the same feature? Can I somehow abuse that behaviour?
I will try to apply your suggestion, but the current structure of the program might make that a little difficult.
-
Since you are loading the icons in another thread, once an icon is loaded, signal that to your model, and from within the model trigger the dataChanged signal accordingly then you should be good to go.