I have a class which is publicly inherited from QWidget
:
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(const MyWidget& other)
:
obj1(other.obj1),
obj2(other.obj2)
private:
some_class obj1;
some_class obj2;
};
When I built my project, compiler complains:
WARNING:: Base class "class QWidget" should be explicitly initialized
in the copy constructor.
I checked out from other questions on stackoverflow, and got my answer.
But the fact is, when I added that initialization like this:
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(const MyWidget& other)
:
QWidget(other), //I added the missing initialization of Base class
obj1(other.obj1),
obj2(other.obj2)
private:
some_class obj1;
some_class obj2;
};
I got compile error:
QWidget::QWidget(const QWidget&) is private within this context
So, please explain me what I am doing wrong.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…