头文件:
#include <QCloseEvent>
.h中申明:
void closeEvent(QCloseEvent *event);
.cpp中添加
//关闭
void Core::closeEvent(QCloseEvent *event)
{
if(QMessageBox::Yes == QMessageBox::question(this, tr("退出程序"),
QString(tr("确认退出程序?")),
QMessageBox::Yes | QMessageBox::No))
{
event->accept();
}
else
{
event->ignore();
}
}
https://blog.csdn.net/bigtree_mfc/article/details/102609450
标签:QT,提示,void,tr,关闭程序,closeEvent,QMessageBox,event From: https://www.cnblogs.com/xiaohai123/p/17259031.html