I didn't find a good answer on the net...
Should i allocate members of a class on heap or stack?
Qt Code:To copy to clipboard, switch view to plain text mode
When should i use heap allocation?
I didn't find a good answer on the net...
Should i allocate members of a class on heap or stack?
Qt Code:To copy to clipboard, switch view to plain text mode
When should i use heap allocation?
Last edited by giowck; 28th November 2009 at 22:43.
Right, but for example if you want only show a dialog and destroy it right afterwards you would normally create it on the stack.
But that's an exeption.Qt Code:
function() { MyDialog d; d.exec(); }To copy to clipboard, switch view to plain text mode
On the stack, because are not childs of QObject...And where to allocate QStrings, QStriglists...? They are kids of QObject...
giowck (28th November 2009)
yeah, now i get it! They aren't QObjects!! Thanks for your answer
Cause i saw QString allocated on the stack in lastfm src code...
But now i checked it...
BTW thanks for the exception (function() on stack)
Solved!
giowck (29th November 2009)
Bookmarks