Hi, I'm a Qt beginner.
I've got problems dealing with inheritance and qwidget :
I've got a class that does all the painting stuff on a widget : class Current.
I've got a class Mother, and a class Son and a class Daugther that inherit from her.
In my class Current, I've got a static list of Mother elements(that can either be Son or Daughter) : static QList<Mother*> mother_list.
I do some : mother_list.append(new Son(attributes));
What I want is : for all the elements of my mother_list, I throw a method draw (virtual) so that the Son and Daughter can do some painting stuff themselves. So they have to have some link with the widget created in the Current Class.
The problem I have is that when I call "draw", the method is never called in the class Son or Daughter.
I think I've done big mistakes with passing the arguments, with the inheritance. Here is a part of the .h :
{
public :
Mother
(QWidget *parent,
const Obj1
&o1,
const Obj2
&ob2
);
virtual ~Mother();
virtual void draw()=0;
......
class Mother: public QWidget
{
public :
Mother(QWidget *parent, const Obj1&o1, const Obj2&ob2);
virtual ~Mother();
virtual void draw()=0;
......
To copy to clipboard, switch view to plain text mode
class Son: public Mother
{
public :
Son
(QWidget *parent,
const Obj1
&ob1,
const Obj2
&ob1,
const Obj3
&Ob3,
const Obj4
&Ob4
);
~Son();
void draw();
...
protected :
class Son: public Mother
{
public :
Son(QWidget *parent, const Obj1&ob1, const Obj2&ob1, const Obj3&Ob3, const Obj4&Ob4);
~Son();
void draw();
...
protected :
void paintEvent(QPaintEvent *);
To copy to clipboard, switch view to plain text mode
Daugher is the same as son.
So when in my current class I call mother_list.at(i)->draw();
Nothing is called.
Can you help me please !!!
Bookmarks