MessageBox.h 971 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef MESSAGEBOX_H
  2. #define MESSAGEBOX_H
  3. #include <QWidget>
  4. #include <QScopedPointer>
  5. class MessageBoxPrivate;
  6. class MessageBox : public QWidget
  7. {
  8. Q_OBJECT
  9. Q_DISABLE_COPY(MessageBox)
  10. public:
  11. enum Type {
  12. T_Show = 0,
  13. T_Hide = 1,
  14. };
  15. explicit MessageBox(QWidget *parent = NULL);
  16. ~MessageBox();
  17. void setText(const QString &text);
  18. void setAutoHide(const bool flag);
  19. void setBackgroundBmpPath(const QString& path);
  20. void setFontPointSize(const int pointSize);
  21. protected:
  22. void styleChange();
  23. void showEvent(QShowEvent *event);
  24. void hideEvent(QHideEvent *event);
  25. void paintEvent(QPaintEvent *event);
  26. void mouseReleaseEvent(QMouseEvent *event);
  27. signals:
  28. void messageWidgetChange(const MessageBox::Type type);
  29. void messageShowTimeout();
  30. private slots:
  31. void onTimeOut();
  32. private:
  33. friend class MessageBoxPrivate;
  34. QScopedPointer<MessageBoxPrivate> m_Private;
  35. };
  36. #endif // MESSAGEBOX_H