我用下面的代码回放保存在DAT文件中的GPS数据,结果是它只回放一组数据,请问该如何改进呢?
void MainWindow::showBackDataSlot(){ QString s = QFileDialog::getOpenFileName(this, tr("open the file"), tr("data")); QFile file(s); QByteArray buf1;// char *chxym;// QByteArray chx; QByteArray ch; if(file.open(QIODevice::ReadOnly)) { buf1 = file.readAll();//读取所有内容 } ch = buf1.data(); qDebug()<<tr("读取结束"); file.close(); if(!ch.isEmpty()) //读取GPS数据,数据格式:$GNRMC,114610.00,A,4546.53240,N,12640.75738,E,4.159,330.63,070719,,,A*78 { if(ch.contains("$GPRMC")) { qDebug()<<"2222"; ch.remove(0,ch.indexOf("$GPRMC")); if(ch.contains("*")) { COM_HPR=ch.left(ch.indexOf("*")); list.clear(); list<<COM_HPR.split(','); GpsDisplay(); qDebug()<<"33333"; } } }}