当前位置:网站首页>Simple read / write verification of qdatastream
Simple read / write verification of qdatastream
2022-07-01 05:06:00 【Autodesk_ Glodon】
The purpose is to write binary files and read contents :
#include <QApplication>
#include <QFile>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFile aFile1("file.dat");
if (!(aFile1.open(QIODevice::WriteOnly)))// Open file in write only mode
return -1;
QDataStream bStream(&aFile1);
bStream.setVersion(QDataStream::Qt_5_9);
// Write the total size information space in turn , File name size information space , file name
QString currentFileName = "abcdFile" ;
qint64 v1 = 0,v2 = 0;
bStream << qint64(v1) << qint64(v2) << currentFileName;
// Cursor returns to the beginning of the file qint64 Make changes
bStream.device()->seek(0);
v1 = 13548,v2 = 8;
bStream<< qint64(v1) << qint64(v2);
// This step is to refresh the file , Let the written document take effect
aFile1.flush();
aFile1.close();
// Read dat file
QFile aFile2("file.dat");
if (!(aFile2.open(QIODevice::ReadOnly)))// Open file in write only mode
return -1;
QDataStream aStream(&aFile2);
aStream.setVersion(QDataStream::Qt_5_9);
qint64 v3 = 0,v4 = 0;
aStream >> v3 >> v4 >> currentFileName;// Reading data , Deposit in tem and str
qDebug() << v3 << v4 << currentFileName ;// Print it out and see the result
aFile2.close();
return a.exec();
}
边栏推荐
- 複制寶貝提示材質不能為空,如何解决?
- 导电滑环短路的原因以及应对措施
- Take a cold bath
- AcWing 885. Find the combination number I (recursive preprocessing)
- Global and Chinese markets of Ethernet communication modules 2022-2028: Research Report on technology, participants, trends, market size and share
- Leetcode316- remove duplicate letters - stack - greedy - string
- [hard ten treasures] - 1 [basic knowledge] classification of power supply
- Global and Chinese market of mainboard 2022-2028: Research Report on technology, participants, trends, market size and share
- Buffer stream and transform stream
- 手动实现一个简单的栈
猜你喜欢

LeetCode522-最长特殊序列II-哈希表-字符串-双指针
![[NLP Li Hongyi] notes](/img/8e/a51ca5eee638facd54270fb28d2fce.jpg)
[NLP Li Hongyi] notes

Unity drags and modifies scene camera parameters under the editor

STM32扩展版 按键扫描

STM32扩展板 数码管显示

Single page application

每日一题-LeetCode1175-质数排列-数学

Solution: drag the Xib control to the code file, and an error setvalue:forundefined key:this class is not key value coding compliant for the key is reported

Use and modification of prior network model

分布式全局唯一ID解决方案详解
随机推荐
Leetcode1497- check whether array pairs can be divided by K - array - hash table - count
Solve the problem that the external chain file of Qiankun sub application cannot be obtained
分布式全局唯一ID解决方案详解
【暑期每日一题】洛谷 P2637 第一次,第二次,成交!
Like cloud functions
C# wpf 使用DockPanel实现截屏框
Design experience of Meizhou clinical laboratory
AcWing 884. Gauss elimination for solving XOR linear equations
Basic skeleton of neural network nn Use of moudle
智慧运维:基于 BIM 技术的可视化管理系统
Pytoch (IV) -- visual tool visdom
积分商城游戏能够给商家带来什么?怎么搭建积分商城?
分布式数据库数据一致性的原理、与技术实现方案
线程安全问题
Global and Chinese markets of InGaAs APD arrays 2022-2028: Research Report on technology, participants, trends, market size and share
科研狗可能需要的一些工具
【暑期每日一题】洛谷 P7222 [RC-04] 信息学竞赛
打印流与System.setout();
Neural network - nonlinear activation
Global and Chinese market of metal oxide semiconductor field effect transistors 2022-2028: Research Report on technology, participants, trends, market size and share