QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "确认关闭", "你确定要关闭窗口吗?",QMessageBox::Yes | QMessageBox::No);// 弹出一个消息框询问用户是否确定关闭窗口
if (reply == QMessageBox::Yes) {
// 允许关闭窗口
} else {
// 阻止关闭窗口
}