[Development] QML, Widgets, and setParent
Kevin Krammer
kevin.krammer at kdab.com
Tue Nov 5 09:55:25 CET 2013
On Monday, 2013-11-04, 21:48:11, Alan Alpert wrote:
> On Sat, Nov 2, 2013 at 5:06 AM, Kevin Krammer <kevin.krammer at kdab.com>
wrote:
> > The thing is that the widgets wouldn't have non-Widget parents, at least
> > not in DeclarativeWidgets. The parent is either a widget or, most of the
> > times, a layout. The layouts' addWidget methods reparent to their parent
> > widget.
> >
> > Therefore one option might be to just not call set parent on widget
> > objects
> > and let the list property code deal with reparenting.
>
> I'm surprised this works. There's implicit QObject parenting built
> into the language, for example:
> QtObject {
> id: foo
> property Widget bar: Widget{}
> }
>
> Will automatically make foo the qobject parent of bar.
>
> I'm not certain, but I think this happens before it gets assigned to
> the property which might make any declarative widgets example using
> layouts crash in debug builds...
Interesting, will have to try that. So far we've never used a widget as a
named property, only ever as part of a declarative list property.
Cheers,
Kevin
--
Kevin Krammer | kevin.krammer at kdab.com | Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5918 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131105/821c5490/attachment.bin>
More information about the Development
mailing list