void ParseLog::readData()
{
QFile file(QDir::currentPath()+"data.txt");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug()<<"Can't open the file!"<<endl;
}
while(!file.atEnd())
{
QByteArray line = file.readLine();
QString str(line);
//qDebug()<< str;
QStringList list = str.split("\"");
processData(list.at(3));
}
file.close();
}
void ParseLog::processData(QString str)
{
char data[520] = {0};
QByteArray byte;
//----------------
byte = QByteArray::fromHex(str.toUtf8());
qDebug() <<"---------"<< byte.toHex();
memcpy(data,byte,byte.size());
}
QT如何读取txt文件中的二进制数据,并解析
最新推荐文章于 2023-12-16 22:54:19 发布