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

knowledge seeker knowledgeseeker78 at gmail.com
Thu Mar 5 06:02:19 CET 2009


Its not that - "what can be done", I was just curious that the code
snippet had a memory leak or not, by just looking at it at one glance
(considering there are no code-tweaks occuring behind the scenes).

Or, shall I presume that Qt::WA_DeleteOnClose attribute is set-as-default ?

Regards,
Knowledge Seeker


On Thu, Mar 5, 2009 at 9:21 AM, Malyushytsky, Alex <alex at wai.com> wrote:
> QApplication can't be parent object for widget, cause it is not a widget.
>
> There is no difference in the memory management in the code when you have main window or you have any other widget shown instead.
>
> For example you can set Qt::WA_DeleteOnClose attribute with QWidget::setAttribute(), so widget will delete itself when closed or you can do it somewhere as a result of lastWindowClosed () or just allocate your widget on a stack.
>
> Hope this helps,
>    Alex
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Knowledge Seeker
> Sent: Wednesday, March 04, 2009 5:43 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] show a widget without a main window
>
> Is not there a memory leak? there is no
> delete w;
> And also object 'w' is not linked to the parentobject - QApplication, so
> it cant be automatically deleted !!
>
>
> Regards,
> Knowledge Seeker
>
> Malyushytsky, Alex wrote:
>>
>> Most of Qt examples are not using main window. Example look like this:
>>
>> #include <QtGui>
>>
>> #include "myWidget.h"
>>
>> //! [main function]
>>
>> int main(int argc, char *argv[])
>>
>> {
>>
>> QApplication app(argc, argv);
>>
>> myWidget *w = new myWidget;
>>
>> w->show();
>>
>> return app.exec();
>>
>> }
>>
>> Regards
>>
>> Alex Malyushyutsky
>>
>> ------------------------------------------------------------------------
>>
>> *From:* qt-interest-bounces at trolltech.com
>> [mailto:qt-interest-bounces at trolltech.com] *On Behalf Of
>> *ri at eeda.denso.co.jp
>> *Sent:* Tuesday, March 03, 2009 8:56 PM
>> *To:* qt-interest at trolltech.com
>> *Subject:* [Qt-interest] show a widget without a main window
>>
>> Hi
>>
>> I would like to know that if it's possible to show a widget without a
>> main window.
>>
>> For example, I want to show a QTableWidget, but only a QTableWidget,
>>
>> not a QTableWidget inside a QMainWindow.
>>
>> Is it possible? if yes, any sample code?
>>
>> Thanks in advance!
>>
>> Shiniji,Mizuki
>>
>>
>>
>> ---------------------------------------------------------------------------------------------------
>> Weidlinger Associates, Inc. made the following annotations.
>>
>> "This message and any attachments are solely for the intended
>> recipient and may contain confidential or privileged information. If
>> you are not the intended recipient, any disclosure, copying, use, or
>> distribution of the information included in this message and any
>> attachments is prohibited. If you have received this communication in
>> error, please notify us by reply e-mail and immediately and
>> permanently delete this message and any attachments. Thank you."
>>
>> "Please consider our environment before printing this email."
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> "This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
>
> _______________________________________________
> 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