首先要调用

#include <QMessageBox>

然后

            QMessageBox msgBox;
            msgBox.setWindowTitle("错误");
            msgBox.setText("除数不能为零");
            msgBox.exec();
    

或者简单点

QMessageBox::warning(this,"错误","除数不能为零");

常用的弹出框类型

  1. Question
    For asking a question during normal operations.
  2. Information
    For reporting information about normal operations.
  3. Warning
    For reporting non-critical errors.
  4. Critical
    For reporting critical errors.

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
  • 2022-01-05
  • 2021-09-27
  • 2022-12-23
猜你喜欢
  • 2022-02-24
  • 2021-08-12
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案