-
Notifications
You must be signed in to change notification settings - Fork 2
/
qt_ext_button.h
44 lines (37 loc) · 1.02 KB
/
qt_ext_button.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
#ifndef QT_EXT_BUTTON_H
#define QT_EXT_BUTTON_H
#include <QPushButton>
#include <QWidget>
#include <QPixmap>
class QtExtButton : public QPushButton
{
enum class ButtonState
{
Normal,
Hover,
Pressed,
Disabled,
};
struct BTN_IMAGE
{
QPixmap normal_pixmap_;
QPixmap hover_pixmap_;
QPixmap pressed_pixmap_;
QPixmap disabled_pixmap_;
};
public:
QtExtButton(QWidget *parent = nullptr);
~QtExtButton();
// 0 normal, 1 hover, 2 pressed, 3 disabled
void setImagePath(const QStringList &path);
protected:
virtual void paintEvent(QPaintEvent *ev) override;
virtual void enterEvent(QEvent *event) override;
virtual void leaveEvent(QEvent *event) override;
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
private:
ButtonState state_ = ButtonState::Normal;
BTN_IMAGE btn_image_;
};
#endif // QT_EXT_BUTTON_H