Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Does QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap & pixmap, QGraphicsItem * parent = 0) perform a Deep Copy of pixmap



  • I'm considering implementing a ResourceManager class to store all of the QPixmaps which would appear in my game, but am wondering if the constructor QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap & pixmap, QGraphicsItem * parent = 0) performs a deep copy of the pixmap parameter. It seems pretty wasteful to me for each QGraphicsPixmapItem to store its own copy of the QPixmap, but the constructor accepts a constant reference instead of a pointer and QGraphicsPixmapItem::pixmap() returns a copy, not a (constant) reference of its QPixmap.



  • QPixmap uses implicit sharing, so if pixmap doesn't change, all graphicsitems use the same pixmap.



  • It seems your goal is to have something as "QPixmapCache":http://doc.trolltech.com/4.6-snapshot/qpixmapcache.html, isn't it?


Log in to reply