-
Notifications
You must be signed in to change notification settings - Fork 0
/
mypushbutton.cpp
62 lines (44 loc) · 1.59 KB
/
mypushbutton.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
#include "mypushbutton.h"
#include <QPropertyAnimation>
MyPushButton::MyPushButton(QWidget *parent) : QPushButton(parent) {
}
MyPushButton::MyPushButton(const QString &inputpath, const QString &modeinfo) {
inputImgPath = inputpath;
buttonModeInfo = modeinfo;
QPixmap pix;
bool ret = pix.load(inputImgPath);
if (!ret) return;
// set pic size
setFixedSize(pix.width() - 10, pix.height() - 10);
// set Icon size
setIcon(pix);
setIconSize(QSize(pix.width(), pix.height()));
}
void MyPushButton::zoomIn() {
QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry");
// set duration
animation->setDuration(50);
// set startvalue & endvalue
animation->setStartValue(QRect(this->x(), this->y(), this->width(), this->height()));
animation->setEndValue(QRect(this->x(), this->y() + 10, this->width(), this->height()));
// set curves
animation->setEasingCurve(QEasingCurve::InOutQuad);
// set loops
animation->setLoopCount(10);
// start animation
animation->start();
}
void MyPushButton::zoomOut() {
QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry");
// set duration
animation->setDuration(50);
// set startvalue & endvalue
animation->setStartValue(QRect(this->x(), this->y() + 10, this->width(), this->height()));
animation->setEndValue(QRect(this->x(), this->y(), this->width(), this->height()));
// set curves
animation->setEasingCurve(QEasingCurve::InOutQuad);
// set loops
animation->setLoopCount(10);
// start animation
animation->start();
}