[Qt-interest] why parent widget in constructor?

Luca Ferrari fluca1978 at infinito.it
Wed Apr 29 08:55:21 CEST 2009


On Monday 27 April 2009 18:01:29 Andreas Pakulat's cat walking on the keyboard 
wrote:
> On 27.04.09 15:06:39, Luca Ferrari wrote:
> > > a) a object hierarchy, that manages itself. If I delete an object in
> > > the hierarchy the whole subtree is deleted, without me needing to do
> > > anything. This is very nice for temporary windows/dialogs, I can create
> > > the window on the stack and even if all its children are created on the
> > > heap, they'll be deleted for me once the window goes out of scope.
> > >

A doubt: so the object tree means that having a widget A that is parent of B 
and C, when A is deleted also B and C are deleted?
In this case, isn't it dangerous if I keep a pointer to B for use in another 
widget? Is there any real case this could happen or it is a bad programming 
style?

Luca






More information about the Qt-interest-old mailing list