-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpillbutton.cpp
More file actions
45 lines (33 loc) · 743 Bytes
/
Copy pathpillbutton.cpp
File metadata and controls
45 lines (33 loc) · 743 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "pillbutton.h"
#include <QPainter>
PillButton::PillButton(QWidget *parent) :
QLabel(parent)
{}
PillButton::PillButton(QWidget *parent, QPixmap px)
: QLabel(parent)
{
pixmap=px;
this->setPixmap(pixmap);
}
void PillButton::mousePressEvent(QMouseEvent *ev) {
this->move(x()+1,y()+1);
emit clicked();
}
void PillButton::mouseReleaseEvent(QMouseEvent *ev)
{
this->move(x()-1,y()-1);
}
void PillButton::enterEvent(QEvent *)
{
QPixmap px(pixmap);
QPainter p(& px );
p.setBrush( QColor( 118,225,209, 127 ) ); // highligh a bit
p.setPen( Qt::NoPen );
p.drawRect( px.rect() );
p.end();
this->setPixmap(px);
}
void PillButton::leaveEvent(QEvent *)
{
setPixmap(pixmap);
}