我有两个类名“mamad”和“student”,它们都继承自我的类“Base”,而“Base”继承自 QObject
在学生班中,我有一个字段:“主题”,它是一个 mamad,我有一个函数(setsubject),它采用一个新主题并将新主题复制到主题。
但我有一个错误:
"QObject& Qobject::operator=(const QObject)" is private !
"within this context"
我该如何解决?
这是我的妈妈课:
class mamad:public Base
{
Q_OBJECT
Q_PROPERTY(int id2 READ getId2 WRITE setId2)
Q_PROPERTY(QString Name2 READ getName2 WRITE setName2)
public:
mamad(Base* parent=0);
int getId2() const { return id2; }
void setId2(int newId) { id2 = newId; }
QString getName2() const { return Name2; }
void setName2(const QString &newName) { Name2 = newName; }
private:
int id2;
QString Name2;
};
这是我的学生班:
class student : public Base
{
Q_OBJECT // Q_OBJECT macro will take care of generating proper metaObject for your class
Q_PROPERTY(int id READ getId WRITE setId)
Q_PROPERTY(QString Name READ getName WRITE setName)
Q_PROPERTY(mamad subject WRITE setsubject)
public:
student(Base * parent=0);
int getId() const { return id; }
void setId(int newId) { id = newId; }
QString getName() const { return Name; }
void setName(const QString &newName) { Name = newName; }
// mamad getsubject()const {return subject;}
void setsubject( mamad newsubject) {subject=newsubject; }
private:
int id;
QString Name;
mamad subject;
};
我必须说我的getsubject函数也有这个问题,我不知道如何解决。?
请,请,帮助我