#ifndef CANVAS_H #define CANVAS_H #include #include #include class Canvas : public QWidget { Q_OBJECT public: explicit Canvas(QWidget *parent = 0); signals: public slots: void clearImage(); protected: void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; private: void drawLineTo(const QPoint &endPoint); void resizeImage(QImage *image, const QSize &newSize); bool scribbling; int myPenWidth; QColor myPenColor; QImage image; QPoint lastPoint; }; #endif // CANVAS_H