-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmypushbutton.cpp
More file actions
33 lines (32 loc) · 1.2 KB
/
mypushbutton.cpp
File metadata and controls
33 lines (32 loc) · 1.2 KB
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
#include "mypushbutton.h"
#include <QPropertyAnimation>
#include <QPushButton>
#include <QDebug>
MyPushButton::MyPushButton(QString img)
{
QPixmap pix;
pix.load(img);
this->setFixedSize(pix.width(),pix.height());
this->setStyleSheet("QPushButton{border:0px;}");
this->setIcon(pix);
this->setIconSize(QSize(pix.width(),pix.height()));
//qDebug()<<pix.width()<<" "<<pix.height();
}
void MyPushButton::btnup()
{
QPropertyAnimation * animation = new QPropertyAnimation(this,"geometry");
animation->setDuration(200);
animation->setStartValue(QRect(this->x(),this->y(),this->width(),this->height()));
animation->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start();
}
void MyPushButton::btndown()
{
QPropertyAnimation * animation = new QPropertyAnimation(this,"geometry");
animation->setDuration(200);
animation->setStartValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
animation->setEndValue(QRect(this->x(),this->y(),this->width(),this->height()));
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start();
}