-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelper.cpp
More file actions
45 lines (37 loc) · 976 Bytes
/
Copy pathhelper.cpp
File metadata and controls
45 lines (37 loc) · 976 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
#include <QtGui>
#include <QPainter>
#include "helper.h"
Helper::Helper()
{
geometry = QRect(0,0,30,30);
}
void Helper::setColor(QColor color)
{
background.setColor(color);
circlePen.setColor(color);
}
void Helper::setGeometry(QRect _geometry)
{
geometry = _geometry;
}
void Helper::paint(QPainter *painter, QPaintEvent *event, QString *type)
{
background.setStyle(Qt::SolidPattern);
painter->translate(1, 1);
painter->save();
painter->setBrush(circleBrush);
painter->setPen(circlePen);
painter->setBackground(background);
if (type->toAscii() == "Circle")
{
painter->drawEllipse(0,0,30,30);
QPainterPath path = QPainterPath();
path.addEllipse(geometry);
painter->fillPath(path, background);
} else if (type->toAscii() == "Square")
{
painter->drawRect(geometry);
painter->fillRect(geometry, background);
}
painter->restore();
}