https://www.cnblogs.com/sklww/p/3810381.html
QMessageBox中的四种对话框
QMessageBox中的四种对话框
ui_dialogtest.h文件:
自动关闭对话框
QMessageBox* box = new QMessageBox;
QTimer::singleShot(2000, box, SLOT(close()));
box->setWindowTitle(tr("警告"));
box->setIcon(QMessageBox::Warning);
box->setText(tr("文件尚未保存,是否保存?"));
QPushButton *yesBtn = box->addButton(tr("是(&Y)"), QMessageBox::YesRole);
box->addButton(tr("否(&N)"), QMessageBox::NoRole);
QPushButton *cancel = box->addButton(tr("取消"), QMessageBox::RejectRole);
box->show();