-
Notifications
You must be signed in to change notification settings - Fork 1
/
Widget.cpp
72 lines (57 loc) · 1.48 KB
/
Widget.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
63
64
65
66
67
68
69
70
71
#include "Widget.h"
void Flare::Widget::paintEvent(QPaintEvent* Event) {
QPainter painter(this);
painter.setPen(BackColor());
painter.setBrush(BackColor());
painter.setRenderHint(QPainter::Antialiasing, true);
painter.drawRoundedRect(1, 1, width() - 2, height() - 2, XRadius(), YRadius(), Qt::AbsoluteSize);
painter.end();
}
void Flare::Widget::enterEvent(QEnterEvent* Event) {
QWidget::enterEvent(Event);
isAbove = true;
}
void Flare::Widget::leaveEvent(QEvent* Event) {
QWidget::leaveEvent(Event);
isAbove = false;
}
void Flare::Widget::mousePressEvent(QMouseEvent* Event) {
QWidget::mousePressEvent(Event);
emit press(Event->pos());
}
void Flare::Widget::mouseReleaseEvent(QMouseEvent* Event) {
QWidget::mouseReleaseEvent(Event);
emit release();
}
Flare::Widget::Widget(QWidget* parent)
: QWidget(parent), backColor(new QColor(FlareColor::White)) {
xRadius = 0;
yRadius = 0;
isAbove = false;
}
Flare::Widget::~Widget(){
qDebug() << "已经调用Widget析构函数";
delete backColor;
}
f32 Flare::Widget::XRadius() const {
return xRadius;
}
f32 Flare::Widget::YRadius() const {
return yRadius;
}
QColor Flare::Widget::BackColor() {
return *backColor;
}
void Flare::Widget::setxRadius(f32 Radius) {
xRadius = Radius;
}
void Flare::Widget::setyRadius(f32 Radius) {
yRadius = Radius;
}
void Flare::Widget::setRadius(f32 XRadius, f32 YRadius) {
xRadius = XRadius;
yRadius = YRadius;
}
void Flare::Widget::setBackColor(const QColor& color) {
*backColor = color;
}