Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

QList strange issue:Qt4.8.4 opensource with VS express 2010

$
0
0
I happened a strange QList issue, QList can’t get list memebers in my application I wrote three class YDBCManager,YDBCMsg,YDBCSig(Ref code following:) and use QList to save the class pointer , like QList <YDBCSig *> m_listSigs; QList <YDBCMsg *> m_listMsgs; YDBCManager manange the QList <YDBCMsg *> m_listMsgs, YDBCMsg manange QList <YDBCSig *> m_listSigs; YDBCManager—->QList<*YDBCMsg>—->QList<*YDBCSig> when I want use code like following , YDBCManager * m_dbcmanager // this declare in the QMainwinows: QMainwinows::slotReadSig() { YDBCMsg * tmpmsg=NULL; YDBCSig * tmpsig=NULL;--    for(int i=0;i<m_dbcmanager ->m_listMsgs.size();i++){    tmpmsg=m_dbcmanager->m_listMsgs.at(i);    out<<"\nMSG:"<<tmpmsg->getMsgName()<<" ID:"<<m_listMsgs.at(i)->getMsgID()<<"\n";    out<<"\t cyclic time:"<<tmpmsg->getMsgcycleTime()<<"\n"; ===> error can't get the size()   for(int j=0;j<m_dbcmanager ->m_listMsgs.at(i)->m_listSigs->size();j++){    tmpsig=m_dbcmanager->m_listMsgs.at(i)->m_listSigs->at(j);    out<<"\t sig["<<j+1<<"]:"<<tmpsig->getSigName()<<"\n";     }   //yDebug(m_dbcmanager->m_listMsgs.at(i)->getMsgName());  }   } I can’t get tmpsig, and get the list size, happend error “Access violation reading location “ is My class definition some problem ,or QList can’t put sub class of QLIST? Any comment welcome! ////////////////////////////////////////////////////////// //// class definition /////////////////////////////////////////////////////////// #ifndef YDBCMSG_H   #define YDBCMSG_H       #include <QList>   #include <QString>       typedef struct _stuTIME_CYCLE{       int id;       int time;   }stuTIME_CYCLE;   //////////////////////////////   //class YDBCSig   // //////////////////////////////   class YDBCSig   {   public:       YDBCSig(const QString & name, int pos,int len);       virtual ~YDBCSig();           void setSigName(const QString&str);       QString getSigName();           void setBitPos(int pos);       int getBitPos();           void setBitLength(int len);       int getBitLength();           void setSigValue(int v);       int getSigValue();           void setSigID(int id);       int getSigID();           private:       QString m_sigName;       int m_bitPos;       int m_bitLength;       int m_sigValue;       int m_sigID;   };   //////////////////////////////   //class YDBCMsg   //   //////////////////////////////   class YDBCMsg   {   public:       YDBCMsg(const QString &name,int id,int len);       virtual ~YDBCMsg();           unsigned char *getMsgFrame();           void add2list(YDBCSig * sig);           void setNodeName(const QString&str);       QString getNodeName();           void setMsgName(const QString&str);       QString getMsgName();           void setMsgID(int id);       int getMsgID();           void setMsgLen(int len);       int getMsgLen();           void setMsgCycleTime(int t);       int getMsgcycleTime();               void setSigValue(int pos,int len,int val);            private:           QString m_msgNode;           QString m_msgName;           int m_msgID;           int m_msgLength;           int m_msgCycleTime;           unsigned char m_msgData[8];     public:           QList <YDBCSig *> m_listSigs;               stuTIME_CYCLE m_timecycle[28];       };   //////////////////////////////   //class YDBCManager   //   //////////////////////////////   class YDBCManager   {   public:       YDBCManager(const QString &fn);       ~YDBCManager();           bool file2msgs();           void setMsgLen(int len);       int getMsgLen();           void add2list(YDBCMsg* msg);           QList <YDBCMsg *> m_listMsgs;           protected:       bool trainLineStr(const QString &str);// how much signal       bool isMsgLine(const QString &line);       bool isSigLine(const QString&line);       bool readSigLine(const QString &line,QString &sig,int &pos,int &size);       bool readMsgLine(const QString &line,QString &msg,int &is, int len);       private:       int m_msgLen;       QString m_fileName;   };       #endif // YDBCMSG_H

Viewing all articles
Browse latest Browse all 13965