消息对话框QMessageBox类提供一个模态对话框来通知用户一些信息,或者向用户提出一个问题并获取答案。
#include
//question Dialog
int ret1 = QMessageBox::question(this, tr("Question Dialog"), tr("Do you know Qt?"),
QMessageBox::Yes,QMessageBox::No);
if(ret1 == QMessageBox::Yes){
qDebug()<
}
//Information Dialog
int ret2 &#61; QMessageBox::information(this, tr("Information Dialog"), tr("This is Qt!"),
QMessageBox::Ok);
if(ret2 &#61;&#61; QMessageBox::Ok){
qDebug()<
}
//Warning Dialog
int ret3 &#61; QMessageBox::warning(this, tr("Warning Dialog"), tr("1111"),
QMessageBox::Abort);
if(ret3 &#61;&#61; QMessageBox::Abort) {
qDebug()<
}
//Critial Dialog
int ret4 &#61; QMessageBox::critical(this, tr("Critial Dailog"), tr("Find a critial question!"),
QMessageBox::YesAll);
if(ret4 &#61;&#61; QMessageBox::YesAll) {
qDebug()<
}
//About Dialog
QMessageBox::about(this, tr("About Dialog"), tr("This is a About Dialog!"));
显示&#xff1a;