[Qt-interest] Using QGraphicsLayouts inside QGraphicsWidgets
Sean Harmer
sean.harmer at maps-technology.com
Mon Jun 27 15:38:27 CEST 2011
On Monday 27 June 2011 15:29:50 Schimkowitsch Robert wrote:
> > 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.
>
> And this is what confuses me. Because QGraphicsLinearLayout is no
> QGraphicsItem subclass. How does it fit into the parent/child hierarchy?
> Why should QGraphicsItem (which knows nothing of layouts) care about a
> QGraphicsLayoutItem?
The parent QGraphicsWidget manages both the layout and the child widgets. That
is the child widgets have your top-level QGraphicsWidget as their parent and
not the layout.
Take a look at the code in QGraphicsWidget destructor to see how and where it
deletes the layout.
The GraphicsItem destructor handles deletion of child QGraphicsItems.
HTH,
Sean
More information about the Qt-interest-old
mailing list