#include <QApplication>
#include <QLabel>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QLabel label("haha");
label.show();
return app.exec();
}
Considering the code above, what’s the difference if I change to QLabel* label = new QLabel("haha") or to QApplication* app = new QApplication(argc, argv)?
Thanks.
Using
newthe objects will be created on the heap instead of the stack. And i guess that’s pretty much it.If you did set the label as the child of another widget and created the parent widget on the stack and the child (in this case the label) on the heap, then you might run into problems when the child is destroyed, but i never tried that to be able to confirm it.