What I should to do to delete QGraphicsItem?
To remove item from the scene I use
QGraphicsScene::removeItem(QGraphicsItem * item);
From the docs for this method:
i.e., QGraphicsScene will no longer delete item when destroyed
So I see only one way:
delete item;
But may be another? For example for QWidget is able to set attribute
setAttribute( Qt::WA_DeleteOnClose );
That causes to deleting of the object. May be there is something similar for QGraphicsItem?
delete item;
– Martin Prazakitem->deleteLater()
– ratchet freakQGraphicsObject
. – thugadeleteLater()
is intended to safely delete objects, which are connected to event loops, so that deletion occurs after all events are processed. If there is no event loop there is no need to usedeleteLater()
nor is it possible absent the event loop, so you justdelete
. – dtech