2 xuwq2015 xuwq2015 于 2015.06.10 16:37 提问

QList添加自定义数据结构出错

这是我自定义的一个类:

 class ConcentratorInfo : public QObject
{
    Q_OBJECT

public:
    explicit ConcentratorInfo(QObject *parent = 0);

public:
    //集中器id
    QString id;

    //集中器地址
    int addr;

    //套接字
    QTcpSocket *socket;

    QString initTime;

    //集中器在线状态
    int status;

    QString quiryTime;

    //线程地址
    DownService *downService;

    /*终端数传机延时时间*/
    int rts;

    /*终端作为启动站允许发送传输延时时间*/
    int sendPropagationDelay;

    /*终端等待从动站响应的超时时间和重发次数*/
    int responseTimeoutSecond;
    int responseTimeoutFrequency;

    /*需要主站确认的通信服务(CON=1)的标志*/
    int needVerifyService;

    /*心跳周期*/
    int heartbeatPeriod;

    /*主站地址*/
    int masterIP1;
    int masterIP2;
    int masterIP3;
    int masterIP4;
    /*主站端口号*/
    int masterPort;
    /*备用ip*/
    int alternateIP1;
    int alternateIP2;
    int alternateIP3;
    int alternateIP4;
    /*备用端口号*/
    int alternatePort;
    /*APN*/
    QString apn;

public:
    Q_INVOKABLE QString idRead();
    Q_INVOKABLE void idWrite(QString);

    Q_INVOKABLE QString addrRead();
    Q_INVOKABLE void addrWrite(QString);

    Q_INVOKABLE int statusRead();
    Q_INVOKABLE void statusWrite(int);

    Q_INVOKABLE int rtsRead();
    Q_INVOKABLE void rtsWrite(int);

    Q_INVOKABLE int sendPropagationDelayRead();
    Q_INVOKABLE void sendPropagationDelayWrite(int);

    Q_INVOKABLE int responseTimeoutSecondRead();
    Q_INVOKABLE void responseTimeoutSecondWrite(int);

    Q_INVOKABLE int responseTimeoutFrequencyRead();
    Q_INVOKABLE void responseTimeoutFrequencyWrite(int);

    Q_INVOKABLE int needVerifyServiceRead();
    Q_INVOKABLE void needVerifyServiceWrite(int);

    Q_INVOKABLE int heartbeatPeriodRead();
    Q_INVOKABLE void heartbeatPeriodWrite(int);

    Q_INVOKABLE int masterIP1Read();
    Q_INVOKABLE void masterIP1Write(int);

    Q_INVOKABLE int masterIP2Read();
    Q_INVOKABLE void masterIP2Write(int);

    Q_INVOKABLE int masterIP3Read();
    Q_INVOKABLE void masterIP3Write(int);

    Q_INVOKABLE int masterIP4Read();
    Q_INVOKABLE void masterIP4Write(int);

    Q_INVOKABLE int masterPortRead();
    Q_INVOKABLE void masterPortWrite(int);

    Q_INVOKABLE int alternateIP1Read();
    Q_INVOKABLE void alternateIP1Write(int);

    Q_INVOKABLE int alternateIP2Read();
    Q_INVOKABLE void alternateIP2Write(int);

    Q_INVOKABLE int alternateIP3Read();
    Q_INVOKABLE void alternateIP3Write(int);

    Q_INVOKABLE int alternateIP4Read();
    Q_INVOKABLE void alternateIP4Write(int);

    Q_INVOKABLE int alternatePortRead();
    Q_INVOKABLE void alternatePortWrite(int);

    Q_INVOKABLE QString apnRead();
    Q_INVOKABLE void apnWrite(QString);

signals:

public slots:
};

#endif // CONCENTRATORINFO_H

这是我定义的一个QList:

 QList<ConcentratorInfo> concentratorList;

但是在使用append添加到一个QList是程序就会报错。

 concentratorList.append(concentratorStruct);

报如下错误:
1、D:\qt5.4.2\5.4\mingw491_32\include\QtCore\qobject.h:463: error: 'QObject::QObject(const QObject&)' is private
Q_DISABLE_COPY(QObject)
^
2、E:\git\windowopener\src\daemon\ConcentratorInfo.h:7: error: within this context
class ConcentratorInfo : public QObject
^
3、D:\qt5.4.2\5.4\mingw491_32\include\QtCore\qglobal.h:1022: error: 'QObject& QObject::operator=(const QObject&)' is private
Class &operator=(const Class &) Q_DECL_EQ_DELETE;
^
4、E:\git\windowopener\src\daemon\ConcentratorInfo.h:7: error: within this context
class ConcentratorInfo : public QObject
^
请问这是问什么?

3个回答

Tiger_Zhao
Tiger_Zhao   Rxr 2015.06.10 16:55
devmiao
devmiao   Ds   Rxr 2015.06.10 17:04

QObject::QObject(const QObject&)' is private
构造函数是私有的
第一行Q_OBJECT,这什么都没有

oyljerry
oyljerry   Ds   Rxr 2015.06.10 22:37

没有拷贝构造函数,需要你实现,

Csdn user default icon
上传中...
上传图片
插入图片