Cremers
13th October 2012, 15:19
Hello, I'm trying to implement a simple class to draw things:
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
Draw.cpp:
#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);
}
I don't understand this error. Incomplete type??
What am I doing wrong?
Thank you.
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
Draw.cpp:
#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);
}
I don't understand this error. Incomplete type??
What am I doing wrong?
Thank you.