[Qt-interest] show a widget without a main window

knowledge seeker knowledgeseeker78 at gmail.com
Tue Mar 10 09:27:33 CET 2009


Sorry for the wrong link.

The correct link is
http://doc.trolltech.com/4.4/tutorials-tutorial-t5.html

In constructor of MyWidget() please see that
 QPushButton *quit = new QPushButton(tr("Quit"));

Hence there is no this passed as parameter, while creating the quit-object.

Now what do you suggest ?

Does layout->addWidget(quit);  take care of the before-mentioned
parent-child delete-mechanism ??

If yes, then does setLayout() method also somehow helps deleting the
object QVBoxLayout *layout ??



On Mon, Mar 9, 2009 at 10:23 PM, Andreas Pakulat <apaku at gmx.de> wrote:
> On 09.03.09 19:25:18, Knowledge Seeker wrote:
>> Thanks for throwing more light on it.
>> And I am programming since the days of DOS, in which it definitely was a
>> memory leak :-).
>>
>> So keeping the above in mind what do you say for the example code given at:
>> http://doc.trolltech.com/4.4/tutorials-tutorial-t4.html
>>
>> Isn't QPushButton *quit object causing a memory-leak ! ? !
>
> No, because it has this as parent, which means it'll be deleted when this
> is deleted (i.e. the widget).  Thats what people said at the start of this
> thread, qobject-parent-child relationships relieves you from memory
> management, as long as you delete the top-level qobject of your
> objec-tree's at some point.
>
> Andreas
>
> --
> Don't relax!  It's only your tension that's holding you together.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




More information about the Qt-interest-old mailing list