[Qt-interest] Using QGraphicsLayouts inside QGraphicsWidgets
Sean Harmer
sean.harmer at maps-technology.com
Mon Jun 27 14:14:56 CEST 2011
On Monday 27 June 2011 14:12:23 Schimkowitsch Robert wrote:
> > I think you think (and digg) too much :)
> >
> > In general the QGWidget will be the parent of both the items of the
>
> layout and
>
> > the layout itself, and delete them both when destroyed.
>
> I like to understand things at least once, when I first use them.
> Usually, what the docs say is enough, but this is a case where I really
> couldn't guess the true behaviour from the docs.
>
> And the question whether I need to delete my item or not is of some
> consequence to me.
>
> BTW actual debugging confirmed that the item is deleted for me.
> I would like to understand why and how, but I'd be happy if someone just
> confirmed that this is the intended behaviour.
QGraphicsItem from which QGraphicsWidget inherited indirectly is responsible
for deleting any child graphics items. This is analogous to how QObject
derived items delete their children in the rest of Qt.
The reason that QGraphicsItem does not simply inherit from QObject is that
QGraphicsItem was designed to be as light-weight as possible. Take heed of the
note in QGraphicsObject that it is the QGraphicsItem part of the object that
handles the child object management tasks rather than QObject.
HTH,
Sean
More information about the Qt-interest-old
mailing list