Re: Inheritance and QpaintEvent
Quote:
Originally Posted by jacek
If it's just "an object" then you shouldn't derive it from QWidget. Everything what inherits QWidget is a widget.
In Qt4 you can draw on widgets only in their paintEvent() method. This means that you have to invoke Son::draw() from your widget's paintEvent().
Ok, so here what I don t understand :
In my Current class, where I do all the drawing in the Current::paintEvent.
I create a Son(which is not a Widget), and I call Son->draw().
I want this function for example to draw an ellipse on the Current (which is the widget).
So in Son::draw I just do update(), which calls the Son::paintEvent which will draw the Ellipse.
Then, in my Son::paintEvent what do I do ???? that s the point that I do not understand !!! I can t do QPainter painter(this)
son.cpp(106): error C2664: 'QPainter::QPainter(QPaintDevice *)'*: impossible de convertir le paramètre 1 de Son*const ' en 'QPaintDevice *'
That s why I was doing all the thing with passing the Widget to the Son so he knows where to draw !!!!!
Re: Inheritance and QpaintEvent
Quote:
Originally Posted by djoul
Ok, so here what I don t understand :
In my Current class, where I do all the drawing in the Current::paintEvent.
I create a Son(which is not a Widget), and I call Son->draw().
So in this case you should have something like this:
Code:
class Son
{
public:
Son() { ... }
{
painter.drawEllipse( ... );
...
}
...
};
{
...
Son s;
s.draw( this );
...
}
Re: Inheritance and QpaintEvent
Jacek, A statue of you should be built for the help you gave me, it WORKS.
THANK YOU,
YYYYYYYYYYYHHHHHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA