1. 拖动一个pushbutton,改名为show message
2.增加一个clicked()的slot
3.在增加的函数里面写入如下语句
void MainWindow::on_pushButton_2_clicked()
{
QMessageBox::information(this, tr("The Title"),tr("This is a message "));
}
4.由于引用了QMessageBox所以我们需要在mainwindow.cpp开头加上
#include <QMessageBox>
5.可以更改函数得到不同的效果
QMessageBox::warning(this, tr("The Title"),tr("This is a message "));
QMessageBox::question(this, tr("The Title"),tr("This is a message "));
QMessageBox::critical(this, tr("The Title"),tr("This is a message "));