首先要调用
#include <QMessageBox>
然后
QMessageBox msgBox;
msgBox.setWindowTitle("错误");
msgBox.setText("除数不能为零");
msgBox.exec();
或者简单点
QMessageBox::warning(this,"错误","除数不能为零");
常用的弹出框类型
- Question
For asking a question during normal operations. - Information
For reporting information about normal operations. - Warning
For reporting non-critical errors. - Critical
For reporting critical errors.