[Qt-interest] remove QgRaphicsItem from parent

Rainer Wiesenfarth Rainer.Wiesenfarth at inpho.de
Thu Oct 8 16:31:11 CEST 2009


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3438 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091008/8e0f276a/attachment.bin 


More information about the Qt-interest-old mailing list