-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanvas.cpp
More file actions
43 lines (33 loc) · 723 Bytes
/
canvas.cpp
File metadata and controls
43 lines (33 loc) · 723 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
#include "canvas.h"
#include <QPainter>
#include <QPaintEvent>
Canvas::Canvas()
{
}
Canvas::~Canvas()
{
}
QPoint Canvas::Origin() const
{
return xform.map(QPoint(0,0));
}
void Canvas::SetPixmap(const QPixmap & pix)
{
pixmap = pix;
QLabel::setPixmap(pix);
}
void Canvas::paintEvent(QPaintEvent *e)
{
QPainter painter;
painter.begin(this);
painter.setClipRect(e->rect());
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
painter.setBackgroundMode(Qt::TransparentMode);
painter.setTransform(xform);
painter.drawPixmap(QPointF(0, 0), pixmap);
}
void Canvas::resizeEvent(QResizeEvent* e)
{
QLabel::resizeEvent(e);
}