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

Andreas Pakulat apaku at gmx.de
Thu Mar 5 09:19:10 CET 2009


On 05.03.09 07:13:03, Knowledge Seeker wrote:
> 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 !!

Yes, but the leak exists only for a very short timeframe usually as its
most of the time the last widget you close and when that happens the
app.exec() call returns and main() is exited. At that point the
operating system will re-claim all memory used by the application. So
the leak only exists between closing the widget and exiting the
application, which is usually acceptable, especially for demo apps.

Of course this is different if that initial widget creates other
top-level widgets and you then close the initial widget. In that case it
should delete itself when its closed, or should be deleted from
somewhere else.

Andreas

-- 
Chess tonight.



More information about the Qt-interest-old mailing list