-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskinpushbutton.cpp
More file actions
37 lines (30 loc) · 1.08 KB
/
Copy pathskinpushbutton.cpp
File metadata and controls
37 lines (30 loc) · 1.08 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
34
35
36
37
#include "skinpushbutton.h"
#include <QIcon>
skinPushButton::skinPushButton(QString picName,QString tipInfo,QWidget* parent):QPushButton(parent)
{
this->setToolTip(tipInfo);
this->setFlat(true);
this->setWindowOpacity(0);
pixMap.load(":/img/sysButton/"+picName);
iconWidth=pixMap.width()/3;
iconHeight=pixMap.height();
this->setIcon(QIcon(pixMap.copy(0,0,iconWidth,iconHeight)));
this->setIconSize(QSize(iconWidth,iconHeight));
}
void skinPushButton::enterEvent(QEvent *){
this->setWindowOpacity(0.1);
this->setIcon(QIcon(pixMap.copy(iconWidth,0,iconWidth,iconHeight)));
}
void skinPushButton::mousePressEvent(QMouseEvent *e){
this->setWindowOpacity(0.3);
this->setIcon(QIcon(pixMap.copy(iconWidth*2,0,iconWidth,iconHeight)));
}
void skinPushButton::leaveEvent(QEvent *){
this->setWindowOpacity(0);
this->setIcon(QIcon(pixMap.copy(0,0,iconWidth,iconHeight)));
}
void skinPushButton::mouseReleaseEvent(QMouseEvent *e){
this->setWindowOpacity(0.1);
this->setIcon(QIcon(pixMap.copy(iconWidth,0,iconWidth,iconHeight)));
emit clicked();
}