• 7416阅读
  • 3回复

读十六进制文件 [复制链接]

上一主题 下一主题
离线jiang_198586
 

只看楼主 倒序阅读 楼主  发表于: 2010-04-21
读十六进制文件,是用QDataStream吗?具体怎么一个一个字节读啊?相关readBytes的用法举例
离线yangfanxing
只看该作者 1楼 发表于: 2010-04-21
QDataStream & QDataStream::readBytes ( char *& s, uint & l )
Reads the buffer s from the stream and returns a reference to the stream.
The buffer s is allocated using new. Destroy it with the delete[] operator.
The l parameter is set to the length of the buffer. If the string read is empty, l is set to 0 and s is set to a null pointer.
The serialization format is a quint32 length specifier first, then l bytes of data.

纯要16进制数据的话我老觉得这个读法。。。不太合适。。。
用重载要好些吧,数据量大的话。。。以下供参考:
  1. QFile fileO(QString & path);
  2. fileO.open(QIODevice::ReadWrite);
  3. QDataStream in(&fileO);
  4. while(!in.atEnd())
  5. {
  6. quint8 tmp = 0;    //tmp数据类型决定了读入方式!
  7. in >> tmp;    //读进一个quint8大小即1Byte的数据;需要每次读入及后续操作多少自己修改之。。。
  8. //...
  9. }
PHPWind好恶心。。。不想看这种界面。。。
离线benbenmajia

只看该作者 2楼 发表于: 2010-04-21
小羊羊你疯了最近,疯狂帖...哥哥我最近在做windows mobile下的东西,directshow,头疼~~
安然.....
离线yangfanxing
只看该作者 3楼 发表于: 2010-04-21
引用第2楼benbenmajia于2010-04-21 17:10发表的  :
小羊羊你疯了最近,疯狂帖...哥哥我最近在做windows mobile下的东西,directshow,头疼~~

啊。。。我往后收敛一点儿。。。
PHPWind好恶心。。。不想看这种界面。。。
快速回复
限100 字节
 
上一个 下一个