-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmaction.cpp
67 lines (62 loc) · 1.76 KB
/
maction.cpp
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
#include "maction.h"
#include "ui_maction.h"
#include <QGraphicsDropShadowEffect>
#include "iconfont.h"
mAction::mAction(QWidget *parent) :
QWidget(parent),
ui(new Ui::mAction)
{
ui->setupUi(this);
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
shadow->setOffset(0, 0);
shadow->setColor(QColor("#444444"));
shadow->setBlurRadius(20);
setGraphicsEffect(shadow);
Iconfont iconfont;
ui->icon04->setFont(iconfont.font);
iconfont.font.setPixelSize(20);
ui->icon05->setFont(iconfont.font);
ui->icon06->setFont(iconfont.font);
ui->icon04->setText(QChar(0xe615));
ui->icon05->setText(QChar(0xe616));
boxs.append(ui->action01);
boxs.append(ui->action02);
boxs.append(ui->action03);
boxs.append(ui->action04);
boxs.append(ui->action05);
boxs.append(ui->action06);
ui->action01->installEventFilter(this);
ui->action02->installEventFilter(this);
ui->action03->installEventFilter(this);
ui->action04->installEventFilter(this);
ui->action05->installEventFilter(this);
ui->action06->installEventFilter(this);
}
mAction::mAction(QWidget *parent, QChar icon, QString text):
QWidget(parent),
ui(new Ui::mAction)
{
ui->setupUi(this);
}
mAction::~mAction()
{
delete ui;
}
bool mAction::eventFilter(QObject *watched, QEvent *event)
{
foreach (QWidget * item, boxs) {
if(watched == item)
{
if (event->type() == QEvent::Enter)
{
qInfo() << "进入";
item->setStyleSheet("background:#E7E7E7;");
}else if ( event->type() == QEvent::Leave )
{
item->setStyleSheet("background:#ffffff;");
}
return false;
}
}
return true;
}