``` int rst = QMessageBox::critical(this,tr("Test Title"),tr("This is just a test\nWhat do you want to do?"),QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); if (rst == QMessageBox::Cancel) qDebug("Cancel"); elseif (rst == QMessageBox::Yes){ returnsave() } else { returnfalse; }
效果图
information 信息
源代码如下
1 2 3 4 5 6 7 8 9 10
``` int rst = QMessageBox::information(this,tr("Test Title"),tr("This is just a test\nWhat do you want to do?"),QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); if (rst == QMessageBox::Cancel) qDebug("Cancel"); elseif (rst == QMessageBox::Yes){ returnsave() } else { returnfalse; }
效果图
question 提问
源代码如下
1 2 3 4 5 6 7 8 9 10
``` int rst = QMessageBox::question(this,tr("Test Title"),tr("This is just a test\nWhat do you want to do?"),QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); if (rst == QMessageBox::Cancel) qDebug("Cancel"); elseif (rst == QMessageBox::Yes){ returnsave() } else { returnfalse; }
效果图
warning 警告
源代码如下
1 2 3 4 5 6 7 8 9 10
``` int rst = QMessageBox::warning(this,tr("Test Title"),tr("This is just a test\nWhat do you want to do?"),QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); if (rst == QMessageBox::Cancel) qDebug("Cancel"); elseif (rst == QMessageBox::Yes){ returnsave() } else { returnfalse; }
效果图
aboutQt
源代码如下
1
QMessageBox::aboutQt(this,"Test");
效果图
about
源代码如下
1 2
``` QMessageBox::about(this,"My App","This is just a demo\nVersion 0.1 Alpha\nWill improve in the following days...");