custommessagebox.h 950 B

1234567891011121314151617181920212223242526
  1. #ifndef CUSTOMMESSAGEBOX_H
  2. #define CUSTOMMESSAGEBOX_H
  3. #include <QMessageBox>
  4. #include <QPushButton>
  5. class CustomMessageBox : public QMessageBox {
  6. Q_OBJECT
  7. public:
  8. explicit CustomMessageBox(QWidget *parent = nullptr);
  9. // 显示确认对话框,返回用户选择的结果
  10. static bool showConfirmDialog(const QString &title, const QString &text, const QString &yesButtonText = "确定",
  11. const QString &noButtonText = "取消", QWidget *parent = nullptr);
  12. // 显示超时等待确认对话框
  13. static bool showTimeoutDialog(const QString &title, const QString &text,
  14. const QString &continueButtonText = "继续等待",
  15. const QString &cancelButtonText = "强制取消", QWidget *parent = nullptr);
  16. private:
  17. void setupButtonStyles(QPushButton *yesButton, QPushButton *noButton);
  18. };
  19. #endif // CUSTOMMESSAGEBOX_H