QListWidget with dynamic icons
-
I would like to have a QListWidget with many items, each containing text and icon in the standard manner. The text identifies the icon, meaning that the icon can be retrieved by using the text as the key.
My problem is that retrieving the icons is a relatively slow operation. Setting up the QListWidget would be much faster if I could only supply the text-part when initially creating the QListWidgetItem, later adding the icons only for the items that are really going to be displayed.
Is there a method by which I could intercept the display of a QListWidgetItem and add the icon just before the item is displayed?
I know that I can do this using QListView, but QListWidget already does much of the needed work.
-
Hi,
What about delegating the icon load to anther thread and then signal a data change when they are ready ?
-
Sorry, I just saw that my suggestion is incomplete. Your model should be queried when needed for the icons so what I was suggesting is that when one is queried, you start loading it and then trigger the dataChanged signal.
-
Which part would like to have more detail on ?
-
I would prefer to use QListWidget, because it is much simpler than using model/view with which I have no experience.
I need some pointers as to what should be done - classes and functions to call.I myself was thinking more in the direction of connecting to the vertical scrollbar of QListWidget and anticipating scrolls, but I'm not sure I would guess correctly from the scroll events exactly which items will be displayed.
-
If you use QListWidget then you don't have any control over the model so you won't be able to move the image loading part outside of it.
-
What option did you choose ?
-
It's good when it's more friendly :)