Hello,
I'm trying to display a line with QPainter with following code:
drawit.h:
#ifndef DRAWIT_H
#define DRAWIT_H
#include <QWidget>
{
Q_OBJECT
public:
protected:
};
#endif
#ifndef DRAWIT_H
#define DRAWIT_H
#include <QWidget>
class DrawIt : public QWidget
{
Q_OBJECT
public:
DrawIt(QWidget *parent = 0);
protected:
QPainter *paint;
};
#endif
To copy to clipboard, switch view to plain text mode
drawit.cpp:
#include <QtGui>
#include "drawit.h"
{
}
{
paint->drawLine(10, 10, 50, 50);
}
#include <QtGui>
#include "drawit.h"
DrawIt::DrawIt(QWidget *parent) : QWidget(parent)
{
paint = new QPainter();
}
void DrawIt::paintEvent(QPaintEvent *)
{
paint->drawLine(10, 10, 50, 50);
}
To copy to clipboard, switch view to plain text mode
main.cpp:
#include <QApplication>
#include "drawit.h"
int main(int argc, char* argv[])
{
DrawIt *drawIt = new DrawIt;
drawIt->show();
return app.exec();
}
#include <QApplication>
#include "drawit.h"
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
DrawIt *drawIt = new DrawIt;
drawIt->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
This gives the error "no 'void DrawIt:
aintEvent(QPaintEvent *)' member function declared in class DrawIt
Where am i making the mistake? 
Thx in advance,
Misko
Bookmarks