[Qt-interest] QGraphicsScene::addItem item has already been added to this scene Error

Riccardo Roasio riccardo.roasio at gmail.com
Fri Jun 18 15:31:25 CEST 2010


Ok,

sorry for replying to you and not to everybody before!
I will check in my code where this happens...

Thanks so much!
Riccardo


2010/6/18 Sean Harmer <sean.harmer at maps-technology.com>:
> Hi,
>
> Please respond to the list. Not to me personally.
>
> On Friday 18 June 2010 13:50:23 you wrote:
>> So if the parent is already in the scene iddon't need to set parent
>> for the child objects?
>
> No. What I said was that if you create a QGraphicsItem with a parent that is
> already in the scene, then you do not need to add the new item to the scene.
>
> For example:
>
> // Create a parent item and add it to the scene
> QGraphicsRectItem* parentRect = new QGraphicsRectItem;
> myScene->addItem( parentRect );
>
> // Create a child of parentRect. No need to explicitly add
> // it to the scene since the parent has already been added
> // and the child item inherits this
> QGraphicsRectItem* childRect = new QGraphicsRectItem( parentRect );
>
> // myScene->addItem( childRect ) would trigger the error you saw
>
> Sean
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list