
Originally Posted by
jacek
Why do you create new widgets if Son is a widget too? Wouldn't it be enough to redraw Son?
But I don t want to create new ones ! Qt does ...
The architecture is :
I've got a class Bck1 and Bck2. In both classes I do some drawing with QPaintEvent (the 2 classes are Widgets).
I ve got then the class Mother with his Son.
And I want the Son to do some drawings in bot he Bck1 and Bck2.
My problem is : Son is not a Widget but he must inherit from QWidget to know where he must paint ?
#include <QWidget>
{
Q_OBJECT
public :
~Bck2();
...
protected :
...}
#include <QWidget>
{
Q_OBJECT
public :
~Bck2();
protected :
}
#include <QWidget>
{
Q_OBJECT
public :
virtual ~Mother();
protected :
};
#include <QWidget>
class Son : public Mother
{
Q_OBJECT
public :
Son(.....);//do I need to put Son(QWidget *parent=0) ... ?????
~Son();
protected :
}
#include <QWidget>
class Bck1: public QWidget
{
Q_OBJECT
public :
Bck1(QWidget *parent = 0);
~Bck2();
...
protected :
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
...}
#include <QWidget>
class Bck2: public QWidget
{
Q_OBJECT
public :
Bck2(QWidget *parent = 0);
~Bck2();
protected :
void paintEvent(QPaintEvent *event);
}
#include <QWidget>
class Mother: public QWidget
{
Q_OBJECT
public :
Mother(QWidget *parent=0);
virtual ~Mother();
protected :
virtual void paintEvent(QPaintEvent *event)=0;
};
#include <QWidget>
class Son : public Mother
{
Q_OBJECT
public :
Son(.....);//do I need to put Son(QWidget *parent=0) ... ?????
~Son();
protected :
void paintEvent(QPaintEvent *event);
}
To copy to clipboard, switch view to plain text mode
Does it seems ok ? I never know if I need to specify *parent or *parent=0, and if I need to put Qwidget *parent in the Son constructor ???
Bookmarks