[Qt-interest] Where to create widgets, on stack or heap ?
Stephen Jackson
spjackson42 at gmail.com
Sat Sep 12 22:03:16 CEST 2009
On Sat, Sep 12, 2009 at 8:03 PM, elizabeta petreska wrote:
> Hello
> I read somewhere that is not safe to create widgets on stack, not even for
> modal dialogs, and that the widgets should always be created on heap. Is
> this correct practice to follow and if yes why?
> And in what circumstances is not safe to create modal dialogs in stack?
> Thanks for your time
If you create any QObject on the stack, you must ensure that it is
destroyed before its parent, if any. This is explained here:
http://doc.trolltech.com/4.5/objecttrees.html
Normally this would be OK in the case of a modal dialog.
--
HTH,
Stephen Jackson
More information about the Qt-interest-old
mailing list