为什么我的公共类赋值失败?
void DTSConcent::ReadMessage()
{
QByteArray buf = m_tcpClient->readAll();//读取数据
if (buf.size() >14)
{
QString s=buf.toHex();
QByteArray hexData = buf.toHex();
char *p = hexData.data();
if (s[0] == 'c'&&s[1] == 'c'&&s[2] == 'a'&&s[3] == 'a')
{
bool ok;
int chNo = s.mid(16, 2).toInt(&ok, 16);
QList<FiberLine> *linss = PubFiberInfo->lines;
*line = linss ->at(0);
uint16_t dd = line->segmentlen;
QString slen = s.mid(4, 8);
int dataLen = slen.toInt(&ok, 16);
//前190米为测试数据,不进行计入,0.4米一个点
uint16_t reallen = dataLen<190/0.4 + 8?0:dataLen-(190/0.4 + 8);
line->reallen = reallen;
qDebug()<<line->reallen;
// line->GetFiberLineMax()
//int len = QString::mid(int position, int n = -1) const
//MainProcess::tfiber->Init();
}
}
}
当再次循环到该方法时,公共变量PubFiberInfo的reallen还是初始化的值。