Qt中自己定义了一个类,使用signal与slot机制,这个类继承自QObject,里面有一个自己定义的带参数的构造函数,还有一些设置private变量的函数,获取private变量值的函数,重载了=,==,!=等操作符,还声明了一下signal,最后还有一些private变量。具体代码如下,
class Devices : public QObject
{
Q_OBJECT
public:
Devices(QObject* parent = 0);
Devices(QString DeviceName,bool role):
deviceName(DeviceName),
cco_if(role){}
~Devices();
void setDeviceName(QString DeviceName){ deviceName = DeviceName;}
void setCcoIf(bool role) {cco_if = role;}
QString getDeviceName(){ return deviceName;}
bool getCcoIf(){return cco_if;}
Devices& operator=(const Devices& dev)
{
deviceName = dev.deviceName;
cco_if = dev.cco_if;
return *this;
}
bool operator ==(const Devices& dev)const
{
return (deviceName == dev.deviceName)&&
(cco_if == dev.cco_if);
}
bool operator !=(const Devices& dev)const
{
return !operator == (dev);
}
QString getHumanName(TU8* userHfid);
signals:
void finishUpgBin(int upg_bin);
void finishUpgFw(int upg_fw);
void finishUpgParam(int upg_param);
private:
QString deviceName;
bool cco_if;
.
.
.
};
结果编译的时候出现以下错误,
错误:C2248: 'QOject::QOject' : cannot access private member declared in class 'QObject',貌似是说QObject对象及派生类不能进行copy与赋值,当我把带参数的构造函数,与重载的运算符的代码都去掉时还是报这样的错,求解。多谢