-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwhiteboard.h
40 lines (34 loc) · 993 Bytes
/
whiteboard.h
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
#ifndef WHITEBOARD_H
#define WHITEBOARD_H
#include <QWidget>
class Whiteboard : public QWidget {
Q_OBJECT
public:
Whiteboard(QWidget *parent = nullptr);
void setPenWidth(int newWidth);
QColor penColor() const {
return curPenColor;
}
int penWidth() const {
return curPenWidth;
}
public slots:
void setPenColor(const QColor &newColor = Qt::red);
void clearImage();
void print();
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private:
void drawLineTo(const QPoint &endPoint);
void resizeImage(QImage *image, const QSize &newSize);
bool penDown = false;
int curPenWidth = 1;
QColor curPenColor = Qt::black;
QImage image;
QPoint lastPoint;
};
#endif // WHITEBOARD_H