/*消息堵塞窗口,堵塞父类窗口.父窗口过小导致消息窗口显示不全,适用全屏的显示窗口.用于部分平台弹窗无法使用情况. */ #ifndef MESSAGEBOX_H #define MESSAGEBOX_H #include #include "ui_global.h" class QEventLoop; class UI_LIBRARY MessageBox : public QWidget { Q_OBJECT public: enum Button{ no=1, yes=2, yes_no=3 }; /*! * \brief showMessage显示消息盒子. * \param parent 父窗口,一般需要的. * \param text 显示的信息. * \param button 消息盒子button 类型. * \return 返回状态 Button 枚举. */ static int showMessage(QWidget *parent, const QString &text, Button button= yes); /*! * \brief showMessage显示消息盒子无button. * \param parent 父窗口,一般需要的. * \param text 显示的信息. */ static int showDuringMessage(QWidget *parent, const QString &text, int duringSeconds=2); protected: explicit MessageBox(QWidget *parent, const QString &text, Button button= yes); explicit MessageBox(QWidget *parent); int exec(); QEventLoop *m_pLoop= nullptr; void paintEvent(QPaintEvent *e); private: bool eventFilter(QObject *watched, QEvent *event); void filterChild(QObject *o); private: QList m_object; }; #endif // MESSAGEBOX_H