QT的一个奇怪问题,设置了Qt::Tool后,点击弹出对话框的确定取消按钮,程序直接退出

Alright, I found the reason. QWidget::create() clears the Qt::WA_QuitOnClose attribute for anything but Qt::Window, Qt::Widget or Qt::Dialog. The workaround is to call for example QWidget::show() first, and set the attribute by hand afterwards:

Qt Code:
#include <QtGui>
 
intmain(intargc, char*argv[])
{
QApplicationapp(argc, argv);
QMainWindowwin(0, Qt::Tool);
win.show(); // must be called before setting Qt::WA_QuitOnClose
win.setAttribute(Qt::WA_QuitOnClose);
returnapp.exec();
}

posted @ 2013-03-31 15:26  奥雷连诺  阅读(1454)  评论(0编辑  收藏  举报