PDA

View Full Version : setCacheMode problem in custom QDeclarativeItem



ugluk
8th June 2013, 16:20
If I set DeviceCoordinateCache on my custom QDeclarativeItem, Qt will render my item (or part of it) into an off-screen QPixmap and then attempt to reuse it on subsequent repaints. The problem is that the bounding rect of my item is quite big, but I don't always expect to repaint it all. Rather, I check the height and contentY of a parent Flickable to decide what to repaint. Now, the problem is, that Qt always wants to store into its cache a portion of my item that is greater than the dimensions of the parent Flickable, but I don't know the portion's dimensions, hence I render into the cache wrongly. There are gaps in the pixmap, stored in the cache, that are not repainted. I have tried to:

- reissue the paint request to fit the parent Flickable, whenever I detect that Qt wants my whole item repainted (this is ignored by Qt),

- clear the pixmap cache to invalidate the cache after Qt requests a full repaint (this does not work either, the cache is not cleared for some reason, even if I call QPixmapCache::clear() and QPixmapCache::setCacheLimit(0)).

If only I knew what portion of my Item is going to be stored in the cache. The field exposedRect in the QStyleOptionGraphicsItem object is of no help, as it encompasses my whole item. Please help.

ugluk
8th June 2013, 21:49
To clear the cache:

hide(); show();

to find out the size of the caching pixmap:

painter->device()->height();

and

painter->device()->width();