-
Notifications
You must be signed in to change notification settings - Fork 10
/
popupwidgetbutton.h
73 lines (62 loc) · 1.45 KB
/
popupwidgetbutton.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* 自定义按钮弹出窗口控件
*
* popupwidgetbutton.h
* 自定义按钮弹出窗口控件头文件。
*
* FlyWM_
* GitHub: https://github.com/FlyWM
* CSDN: https://blog.csdn.net/a844651990
*
*/
#ifndef POPUPWIDGETBUTTON_H
#define POPUPWIDGETBUTTON_H
#include <QWidget>
#include <QPushButton>
namespace PWB {
enum WidgetOrientation {
Horizontal,
Vertical,
};
}
class QPushButton;
class PopupWidget;
class PopupWidgetButton : public QWidget
{
Q_OBJECT
public:
explicit PopupWidgetButton(PWB::WidgetOrientation orien, QWidget *rootWindow, QWidget *parent = nullptr);
~PopupWidgetButton();
/**
* @brief setMainWidget
* 设置弹出的widget
* @param widget
*/
void setMainWidget(QWidget *widget);
/**
* @brief setButtonObjectName
* 设置按钮 objectname,方便设置样式表
* @param name
*/
void setButtonObjectName(const QString &name);
/**
* @brief button
* 方便设置按钮的一些属性
* @return
*/
QPushButton *button() { return m_pButton; }
protected:
virtual bool eventFilter(QObject *watched, QEvent *event);
signals:
void ButtonClicked();
void OthersClicked();
public slots:
private:
QPushButton *m_pButton;
PWB::WidgetOrientation m_orien;
PopupWidget *m_pMainWidget;
bool m_mainWidgetClicked;
QWidget *m_pRootWindow;
static QList<PopupWidget *> m_pWidgets;
};
#endif // POPUPWIDGETBUTTON_H