Qt-interest Archive, February 2008
Populating a nested QGraphicsScene
Message 1 in thread
I want to populate a QGraphicsScene with QGaphicsItem objects having
children.
1) "item" is a pointer on a QGraphicsItem constructed but not yet added to a
scene.
Can I pass "item" as the parent parameter of QGraphicsItem constructor, to
set it as parent?
Then if I do scene->addItem(item), will it add all children as well?
2)"item" is a pointer on a QGraphicsItem constructed and inserted in the
scene.
If I create a QGraphicsItem having "item" as parent, is it automatically
added to the scene, or do I have to add it manually?
It seems the doc is not 100% clear on this
Thanks,
Etienne
Message 2 in thread
Hi,
On Wednesday 06 February 2008 15:00:06 Etienne Sandré wrote:
> I want to populate a QGraphicsScene with QGaphicsItem objects having
> children.
>
> 1) "item" is a pointer on a QGraphicsItem constructed but not yet added to
> a scene.
> Can I pass "item" as the parent parameter of QGraphicsItem constructor, to
> set it as parent?
> Then if I do scene->addItem(item), will it add all children as well?
I believe so yes.
> 2)"item" is a pointer on a QGraphicsItem constructed and inserted in the
> scene.
> If I create a QGraphicsItem having "item" as parent, is it automatically
> added to the scene, or do I have to add it manually?
It is added automatically. If you then explicitly call add on the item you
will get a debug message saying that the item is already added to the scene.
Sean
--
[ signature omitted ]