Solved Using QSharedPointer with QGraphicsScene
-
Hi,
I currently have normal QGraphicsPixmapItems that I add to the QGraphicsScene. When scene.clear is called, are all these objects deleted? If not would it make be better to use QSharedPointer, so that these objects would be deleted later on when scene.clear() is called?
-
@jkwok678 said in Using QSharedPointer with QGraphicsScene:
When scene.clear is called, are all these objects deleted?
It's clearly documented: QGraphicsScene::addItem(): "This scene takes ownership of the item."
-
@jkwok678 said in Using QSharedPointer with QGraphicsScene:
When scene.clear is called, are all these objects deleted?
It's clearly documented: QGraphicsScene::addItem(): "This scene takes ownership of the item."
-
@Christian-Ehrlicher said in Using QSharedPointer with QGraphicsScene:
"This scene takes ownership of the item."
I don't quite understand what that means.
-
@jkwok678 It answers your question: "When scene.clear is called, are all these objects deleted?". Since the scene takes the ownership it will delete the objects.