[Qt-interest] Using QGraphicsLayouts inside QGraphicsWidgets

Mihail Naydenov mlists at ymail.com
Mon Jun 27 13:39:44 CEST 2011


----- Original Message ----

> From: Schimkowitsch Robert <Robert.Schimkowitsch at andritz.com>
> To: qt-interest at qt.nokia.com
> Sent: Mon, June 27, 2011 2:03:20 PM
> Subject: Re: [Qt-interest] Using QGraphicsLayouts inside QGraphicsWidgets
> 
> > > 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.
> 

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.

MihailNaydenov

> 
> 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
>#####################################################################################
>#
> 
> _______________________________________________
> Qt-interest  mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
> 



More information about the Qt-interest-old mailing list