在 Qt 中用几个不同的流读取同一个文件 [英] Reading the same file with several different streams in Qt

查看:71
本文介绍了在 Qt 中用几个不同的流读取同一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用多个流读取文件以同时访问其中的数据的不同部分,使用 Qt?

Is it possible to read a file using multiple streams to access different portions of data in it at the same time, using Qt?

推荐答案

请注意,Qt 中的流 (QTextStream/QDataStream) 不处理底层设备中的位置.流类只是一个包装器,用于更容易地解析设备内的二进制数据(QFile 实例).

Note that a stream (QTextStream / QDataStream) in Qt doesn't handle the position in the underlying device. A stream class is only a wrapper for easier parsing of the binary data within the device (QFile instance).

因此同一设备(QFile)的两个流将不起作用.

So two streams for the same device (QFile) will not work.

但是,对于同一个底层文件,您可以有多个设备(QFile),然后可以使用另一个流实例读取它们中的每一个.

You can, however, have multiple devices (QFile) for the same underlying file, and each of them can then be read using another stream instance.

这篇关于在 Qt 中用几个不同的流读取同一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆