[Interest] Create the main widget on heap in main()

程梁 devbean at outlook.com
Fri Jan 10 14:02:04 CET 2014


Hi, there! I wonder if I could create the main widget on heap in main()? Following is my example code:
int main(int argc, char *argv[]){    QApplication app(argc, argv);    QLabel *label = new QLabel;    label->show();    return app.exec();}
label should live longer than app so there might be unsafe because any QPaintDevice must have a QApplication.I'm not sure am I right? That's all main widgets should create on stack in main() in order to avoid such things? Or there is no such requirement? If it should on stack, could you give me some examples about the crash when created on heap?
Thank you!
Cheng Liang
Nanjing, China
http://www.devbean.net 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140110/4525a935/attachment.html>


More information about the Interest mailing list