-
Notifications
You must be signed in to change notification settings - Fork 0
/
orer.cpp
30 lines (28 loc) · 918 Bytes
/
orer.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
#include <orer.h>
Orer::Orer(QWidget *parent) : Component(parent) {
resize(50,50);
setComponentType(5);
setValue(0);
}
void Orer::paintEvent(QPaintEvent*) {
// painter and symbol settings
QPainter p(this);
p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
QString oo = "||";
// font customization
QFont font;
font.setPointSize(12);
font.setBold(true);
p.setFont(font);
// pen and brush customizations
QPen linePen;
linePen.setWidth(2);
linePen.setBrush(Qt::black);
linePen.setCapStyle(Qt::RoundCap);
linePen.setJoinStyle(Qt::RoundJoin);
p.setPen(linePen);
p.setBrush(Qt::green);
// drawing border, ellipse and symbol, the offset is needed beacuse the pen's font is 2px wide
p.drawEllipse(rect().x()+1, rect().y()+1, rect().width()-2, rect().height()-2);
p.drawText(rect().x(), rect().y(), rect().width()-1, rect().height()-1, Qt::AlignCenter, oo);
}