Results 1 to 3 of 3

Thread: sharing QPixmap object between QGraphicsPixmapItems

  1. #1
    Join Date
    Nov 2010
    Posts
    31
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default sharing QPixmap object between QGraphicsPixmapItems

    Hi all,

    This is about phone application, tested on N8
    I have lets say 40 objects derived from QGraphicsPixmapItem, these object lets name them "icon", are created in single class "iconView" during application start, every "icon" object uses 5 QPixmaps to visualize its state. Is it worth to load these QPixmaps once in iconView class before creating "icon" objects, and only pass pointers to loaded QPixmaps to each "icon" object, instead of loading every pixmap inside "icon" object multiple times ?
    Every pixmap is about 10k in size, so they are small, but 40*5*10k=2MB, still not much, however, I have also some amount of other objects and recently I had to change epocheapsize in .pro file, because app didn't start.
    So is it worth an effort to share QPixmap between QGraphicsItems or just epochepasize values are really small by default, and I should increase them and forget about issue?

    best regards
    Marek

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: sharing QPixmap object between QGraphicsPixmapItems

    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following user says thank you to spirit for this useful post:

    franki (13th August 2012)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: sharing QPixmap object between QGraphicsPixmapItems

    QPixmap is implicitly shared, so assigning the same QPixmap (by value) in n places does not result in n copies of the pixmap data: they share the same bulk data. If you modify one of the copies then that instance is split from the others and the data is copied at that point in time. Depending on whether you have 40 * 5 distinct images or 40 sets of 5 identical (copied) images then you may not have the memory consumption you are expecting.

Similar Threads

  1. zoom in object QPixmap
    By jackajack01 in forum Qt Programming
    Replies: 1
    Last Post: 23rd July 2012, 23:27
  2. Sharing the same widget object between several tabs
    By Lipton in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2010, 15:21
  3. Set the size of a QPixmap object
    By RogerShen in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2010, 10:35
  4. Replies: 4
    Last Post: 17th October 2009, 22:31
  5. Replies: 1
    Last Post: 21st August 2008, 07:44

Tags for this Thread

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.