[Qt-interest] why parent widget in constructor?
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Sun Apr 26 16:52:55 CEST 2009
>
> In addition to what was said about the object tree's in Qt, note that
> each and every QObject (and all subclasses, so also all QWidget
> subclasses) use a default argument for the parent pointer. So creating
a
> QWidget without a parent and then adding it somewhere into an existing
> widget hierarchy is very much possible. "QWidget* w = new QWidget;"
> works just fine. In fact this is even used for one of the technologies
> that QtGui provides, widgets in graphicsview. Here the widget that is
> embedded is in fact a top-level widget, which is just moved to the
right
> place by the proxy-widget.
>
> Andreas
>
Andreas beat me to it, but the layout system works this way as well..
Luca, you need to read
http://doc.trolltech.com/4.5/object.html
and
http://doc.trolltech.com/4.5/objecttrees.html
Scott
More information about the Qt-interest-old
mailing list