Results 1 to 2 of 2

Thread: setCacheMode problem in custom QDeclarativeItem

  1. #1
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    7
    Qt products
    Qt4

    Default setCacheMode problem in custom QDeclarativeItem

    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.

  2. #2
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    7
    Qt products
    Qt4

    Default Re: setCacheMode problem in custom QDeclarativeItem

    To clear the cache:

    hide(); show();

    to find out the size of the caching pixmap:

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

    and

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

Similar Threads

  1. QGraphicsItem::setCacheMode - how does it work?
    By d_stranz in forum Qt Programming
    Replies: 10
    Last Post: 1st June 2012, 10:52
  2. capturing a QDeclarativeItem into a QPixmap
    By ugluk in forum Qt Programming
    Replies: 0
    Last Post: 7th May 2012, 12:01
  3. data property in QDeclarativeItem. what is it?
    By moti.lahiani in forum Qt Quick
    Replies: 0
    Last Post: 18th November 2011, 10:03
  4. Replies: 5
    Last Post: 15th August 2011, 22:34
  5. Using a QML model from a QDeclarativeItem subclass
    By humbleguru in forum Qt Programming
    Replies: 1
    Last Post: 3rd January 2011, 13:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.