Hello, I'm trying to implement a simple class to draw things:
Draw.h:
#ifndef DRAW_H
#define DRAW_H
#include <QWidget>
//------------------------------------
{
Q_OBJECT
public:
protected:
private:
};
#endif // DRAW_H
#ifndef DRAW_H
#define DRAW_H
#include <QWidget>
//------------------------------------
class Canvas : public QWidget
{
Q_OBJECT
public:
Canvas(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *e);
private:
QImage image;
};
#endif // DRAW_H
To copy to clipboard, switch view to plain text mode
Draw.cpp:
#include <QPainter>
#include "draw.h"
//-------------------------------------------
{
}
//-------------------------------------------
{
QRect r
= e
->rect
();
// error: invalid use of incomplete type 'struct QPaintEvent' p.drawImage(r, image, r);
}
#include <QPainter>
#include "draw.h"
//-------------------------------------------
Canvas::Canvas(QWidget *parent) : QWidget(parent)
{
}
//-------------------------------------------
void Canvas::paintEvent(QPaintEvent *e)
{
QPainter p(this);
QRect r = e->rect(); // error: invalid use of incomplete type 'struct QPaintEvent'
p.drawImage(r, image, r);
}
To copy to clipboard, switch view to plain text mode
I don't understand this error. Incomplete type??
What am I doing wrong?
Thank you.
Bookmarks