-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmybutton.cpp
More file actions
30 lines (27 loc) · 787 Bytes
/
mybutton.cpp
File metadata and controls
30 lines (27 loc) · 787 Bytes
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
#include "mybutton.h"
#include<QPushButton>
mybutton::mybutton(QWidget*parent,QString str,QString picname):QPushButton(parent)
{
this->setFlat(true);
label=new QLabel(str,this);
label->setStyleSheet("QLabel{color:white;}"
"QLabel:hover{background: rgb(25,25,25,125);}");
label->setGeometry(0,0,40,100);
label->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
label->setCursor(Qt::PointingHandCursor);
label->hide();
this->setIcon(QIcon(QPixmap(":/image/"+picname+".png")));
this->setIconSize(QSize(40,100));
}
bool mybutton::eventFilter(QObject *obj, QEvent *event)
{
return eventFilter(obj,event);
}
void mybutton::enterEvent(QEvent *)
{
label->show();
}
void mybutton::leaveEvent(QEvent *)
{
label->hide();
}