[Qt-interest] Using QGraphicsLayouts inside QGraphicsWidgets

Schimkowitsch Robert Robert.Schimkowitsch at andritz.com
Mon Jun 27 13:03:20 CEST 2011


> > In the constructor initialisation list, I initialize my LinearLayout
> > member thus:
> > m_Layout(this)

> Surely that won't work. Did you mean this?

> m_layout( new QGraphicsLinearLayout( this ) )

My original intent before giving the layout a parent was to declare it
thus:
QGraphicsLinearLayout m_Layout;

Now, I have made it a reference (preferred to a pointer, by our coding
standards), and initialize it thus:

m_Layout(*(new QGraphicsLinearLayout(this)))

However, I have not found it explicitly mentioned in the docs whether a
parent QGraphicsLayoutItem will destroy all children on destruction.

As far as I understood the Qt source, calling the QGraphicsLinearLayout
constructor  calls
setOwnedByLayout(true);
which, according to the docs:
"Returns whether a layout should delete this item in its destructor. If
its true, then the layout will delete it. If its false, then it is
assumed that another object has the ownership of it, and the layout
won't delete this item."

However, the parent for m_Layout is a QGraphicsWidget (and therefore a
QGraphicsLayoutItem), but not a layout.
What is the behaviour for this case?

Going through the destructors of QGraphicsWidget and QGraphicsLayoutItem
suggests to me that no-one will delete my m_Layout reference, and I have
to do so myself.


Did I overlook something?

Kind regards

Robert Schimkowitsch

#####################################################################################
This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.
Thank You.
  ANDRITZ HYDRO GmbH
  Rechtsform/ Legal form: Gesellschaft mit beschrankter Haftung / Corporation 
  Firmensitz/ Registered seat: Wien 
  Firmenbuchgericht/ Court of registry: Handelsgericht Wien 
  Firmenbuchnummer/ Company registration: FN 61833 g
  DVR: 0605077 
  UID-Nr.: ATU14756806
#####################################################################################




More information about the Qt-interest-old mailing list