看了幾篇文章
http://www.cppblog.com/biao/archive/2009/07/02/89079.html
http://www.cppblog.com/ming81/archive/2011/06/01/147869.html
http://blog.csdn.net/leonwei/article/details/3703598
基本上第一篇文章的方法就夠用了
1.指定Widget的parent時,在父Widget關閉時,資源會被釋放。
2.沒有指定父Widget時,自己手動delete釋放掉資源,或者調用setAttribute(Qt::WA_DeleteOnClose)函數
以hello,qt爲例
在hello,qt中,我就調用了lab->setAttribute(Qt::WA_DeleteOnClose),而setMainWidget(label)是qt3中的方法。