[Qt-interest] QListView won't repaint DecorationRole on dataChanged()

Josiah Bryan jbryan at productiveconcepts.com
Wed Oct 28 20:19:11 CET 2009


Hello, All -

I've got a custom QAbstractListModel representing a list of "Slides." 
The model returns both a slide title and a slide "icon" from the data() 
method for the Qt::DecorationRole. Works fine "normally."

However, the slide may have items on it which are not fully loaded (e.g. 
an image, etc). In that case, model periodically checks the slides to 
see if they are finished loading.

If they have NOT finished loading, the  data() method returns a generic 
gray pixmap with a pretty little black border and sets a QTimer to emit 
dataChanged() with the proper indexes to cause the list to call data() 
again so the model can check the slide to see if its ready. However, 
once they slide is "ready", it renders the slide to a pixmap and returns it.

The problem is, once it does render the slide and return the "updated" 
pixmap, the list view doesnt paint the correct pixmap! It still shows 
the gray pixmap. However, if I just click on ANY part of the window (not 
even in the list view), then the list view magically repaints itself. I 
can see the QListView requesting the decoration role from my model when 
it should (after I've rendered the "updated" pixmap) - but it never 
paints the pixmap on the screen!

Fine. So I tried emitting a repaintPlease() signal from the model and 
catch it in the window that houses the list view. Upon catching the 
signal, my window calls QListView::update() - no luck. I tried 
::repaint(). No luck. Calling ::clearFocus() and ::setFocus() SOMETIMES 
works - only if the list view has NOT lost focus already between the 
time that the slide was "not ready" and became "ready."

I've even tried calling dataChanged() AGAIN after the slide "became 
ready" and had already rendered the correct pixmap. But that doesnt help.


Any thoughts or ideas?

Thanks!
-josiah


-- 

-=-=-=-=-=-=-=-=-=-=-=-=-
Josiah Bryan
Productive Concepts, Inc.
jbryan at pciint.com
(765) 964-6009, ext. 224




More information about the Qt-interest-old mailing list