forked from zhazhaog/qqmsuic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrankingbox.cpp
80 lines (72 loc) · 1.91 KB
/
rankingbox.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
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "rankingbox.h"
#include "ui_rankingbox.h"
#include "Images.h"
#include "iconfont.h"
RankingBox::RankingBox(QWidget *parent) :
QWidget(parent),
ui(new Ui::RankingBox)
{
ui->setupUi(this);
// 设置图片
Images images;
Iconfont iconfont;
QString path = images.image();
QPixmap pixmap(path);
ui->img->setPixmap(pixmap);
ui->iconerji->setFont(iconfont.font);
ui->iconerji->setText(QChar(0xe637));
iconfont.font.setPixelSize(50);
ui->widget->installEventFilter(this);
ui->play->installEventFilter(this);
ui->play->setFont(iconfont.font);
ui->play->setText("");
}
RankingBox::~RankingBox()
{
delete ui;
}
bool RankingBox::eventFilter(QObject *watched, QEvent *event)
{
if (watched == ui->play)
{
if (event->type() == QEvent::Enter)
{
ui->count->hide();
ui->play->setText(QChar(0xea82));
return true;
}else if (event->type() == QEvent::Leave)
{
ui->count->show();
ui->play->setText("");
return true;
}
}
if (watched == ui->widget)
{
if (event->type() == QEvent::Enter)
{
QPropertyAnimation *a = new QPropertyAnimation(ui->widget,"pos");
a->setDuration(150);
a->setStartValue(QPoint(0,10));
a->setEndValue(QPoint(0,0));
a->start();
qInfo() << "进去";
return true;
}else if (event->type() == QEvent::Leave)
{
QPropertyAnimation *a = new QPropertyAnimation(ui->widget,"pos");
a->setDuration(150);
a->setStartValue(QPoint(0,0));
a->setEndValue(QPoint(0,10));
a->start();
return true;
}
}
return QObject::eventFilter(watched,event);
}
void RankingBox::enterEvent(QEnterEvent *event)
{
}
void RankingBox::leaveEvent(QEnterEvent *event)
{
}