[Interest] How to really delete a QGraphicsItem from QGraphicsScene
Francis Herne
mail at flherne.uk
Fri Feb 24 12:26:28 CET 2017
On Fri, 24 Feb 2017 19:12:18 +0800
jack ma <assangema at gmail.com> wrote:
> Hi,
>
> is it correct to use “delete” directly delete the item ?
>
> or I should first call removeItem() and then call "delete item" to
> remove it?
>
> How are these two ways affect the bsp tree?
>
> Thanks,
> jack
From the docs for ~QGraphicsItem():
> Destroys the QGraphicsItem and all its children. If this item is
> currently associated with a scene, the item will be removed from the
> scene before it is deleted.
> Note: It is more efficient to remove the item from the QGraphicsScene
> before destroying the item.
So either method is safe, but explicitly removing it is better.
-Francis
More information about the Interest
mailing list