[Kde-games-devel] Re: Delete an QCanvasItem

Andreas Beckermann kde-games-devel@mail.kde.org
Sun, 17 Feb 2002 15:21:08 +0100


On Sunday 17 February 2002 15:09, Codemaster wrote:
> hi,
> How can i delete an QCanvasItem from an Canvas during the process of the
> advance-function. I try it with disable all i can find and then make an
> "delete this;" in my advance-function. I found the
> QCanvas::removeItem(QCI*) function but this function doesn't delete the
> instance.
>
> I will be happy about any hint
>
> cu Albrecht

>From QCanvasItem::advance() documentation:
Note that if you reimplement this function, the reimplementation must not 
change the canvas in any way, for example it must not add or remove items. 

QCanvas::advance() iterates a list of QCanvasItems wtice so you must not 
delete any item while the iteration is done. You can delete your item by 
doing a normal 
delete item;
on the item *after* QCanvas::advance() (or before).

Or do I misunderstand the question?

CU
Andi