Hi Gunnar,
 
thank you once again for your answers. I appreciate your effort a lot.
Curt

________________________________

Von: Gunnar Sletta [mailto:[EMAIL PROTECTED]
Gesendet: Mi 17.09.2008 11:17
An: Curt Nowak
Cc: [email protected]
Betreff: Re: AW: [Qt-jambi-interest] Bad widget/layout hierarchy causes JVM 
crash + QObject Tree + Memory management



Curt Nowak wrote:
> Hi Gunnar,
>
> thanks for your reply. Right now, I'm a little confused. I know this
> might be due to a lack of my knowledge on Java in general. To me the
> concept of QObject trees makes perfect sense for C++ as a means for
> convenient memory management. But I can't see the benefit for a Java
> environment where we have the Garbage Collection. In other words:


> * Does a QWidget child/parent relationship serve any purpose other
> than memory management?

Yes, It defines which widgets are sub-widgets of other widgets etc. This
affects rendering order, event propegation, etc. Same as you have in any
other GUI toolkit.

 > * In Qt Jambi, do I have to specify parents
> for my widgets at all? If yes, in what cases do I have to do that?

No, almost never. When you use layouts e.g.

QHBoxLayout layout = new QHBoxLayout(window);
layout.addWidget(new QPushButton("Button 1"));
layout.addWidget(new QPushButton("Button 2"));

The layout will reparent the widgets as they should be.

If you set a toolbar on a QMainWindow, the mainwindow will reparent, and
same for menus, etc, so there are very few cases where the explicit
parent is required.

 > * Will I have memory leaks if I don't explicitly built such a
> hierarchy?

You shouldn't have, and I'm looking into your other report right now to
figure out why a reference to the top-level is retained even though it
shouldn't.

best regards,
Gunnar





_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to