[Qt-interest] remove QgRaphicsItem from parent
Riccardo Roasio
riccardo.roasio at gmail.com
Thu Oct 8 16:39:59 CEST 2009
I know....
after doing a ~GGraphicsItem
i do a elemenents.clear so the problem is not present..
The problem is that elements continue to be displayed on the screen
while i would like to remove them from the screen...
2009/10/8 Rainer Wiesenfarth <Rainer.Wiesenfarth at inpho.de>:
>
> From: Riccardo Roasio [mailto:riccardo.roasio at gmail.com]
>> But it seems not to work..
>>
>> i use this code:
>>
>> for(int i=0;i<elements.size();i++)
>> {
>> ReceiptElement *e=elements.at(i);
>> e->~QGraphicsItem();
>> }
>>
>> [...]
>
> Should read similar to this:
>
> while (! elements.isEmpty ())
> {
> delete elements.takeFirst ();
> }
>
> You have to use "delete e;" instead of "e->~QGraphicsItem();", but
> delete'ing "e" without removing it from the list will cause a dangling
> reference in the list.
>
> If you are new to C++, I would like to recommend lecture of
> http://www.parashift.com/c++-faq-lite/ or similar. It is worth been read
> even for advanced C++ programmers.
>
> Best Regards / Mit freundlichen Grüßen
> Rainer Wiesenfarth
>
> --
> INPHO GmbH * Smaragdweg 1 * 70174 Stuttgart * Germany
> phone: +49 711 2288 10 * fax: +49 711 2288 111 * web: www.inpho.de
> place of business: Stuttgart * managing director: Johannes Saile
> commercial register: Stuttgart, HRB 9586
> Leader in Photogrammetry and Digital Surface Modelling
>
More information about the Qt-interest-old
mailing list