当前位置:网站首页>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();
}
边栏推荐
- Basic skeleton of neural network nn Use of moudle
- Global and Chinese markets of InGaAs APD arrays 2022-2028: Research Report on technology, participants, trends, market size and share
- Quelques outils dont les chiens scientifiques pourraient avoir besoin
- Worried about infringement? Must share copyrightless materials on the website. Don't worry about the lack of materials for video clips
- AcWing 884. Gauss elimination for solving XOR linear equations
- How to hide browser network IP address and modify IP internet access?
- JS random verification code
- 【暑期每日一题】洛谷 P2637 第一次,第二次,成交!
- Pytoch (IV) -- visual tool visdom
- LeetCode_ 66 (plus one)
猜你喜欢

C read / write application configuration file app exe. Config and display it on the interface

How to traverse massive data in redis

无器械健身

LeetCode522-最长特殊序列II-哈希表-字符串-双指针

每日一题-LeetCode1175-质数排列-数学
![Solution: thread 1:[< *> setvalue:forundefined key]: this class is not key value coding compliant for the key*](/img/88/0b99d1db2cdc70ab72d2b3c623dfaa.jpg)
Solution: thread 1:[< *> setvalue:forundefined key]: this class is not key value coding compliant for the key*

PR 2021 quick start tutorial, learn about the and functions of the timeline panel

STM32扩展版 按键扫描

分布式-总结列表

Fitness without equipment
随机推荐
Pytoch (I) -- basic grammar
AcWing 884. Gauss elimination for solving XOR linear equations
Thread safety issues
Solve the problem that the external chain file of Qiankun sub application cannot be obtained
LeetCode_58(最后一个单词的长度)
【暑期每日一题】洛谷 P2026 求一次函数解析式
Neural networks - use of maximum pooling
Pico Neo3手柄抓取物体
Unity drags and modifies scene camera parameters under the editor
AcWing 887. Finding combinatorial number III (Lucas theorem)
【暑期每日一题】洛谷 P5886 Hello, 2020!
FileOutPutStream
Overview of the construction details of Meizhou veterinary laboratory
智慧运维:基于 BIM 技术的可视化管理系统
Global and Chinese markets of superconductor 2022-2028: Research Report on technology, participants, trends, market size and share
Detailed explanation of distributed global unique ID solution
洗个冷水澡吧
[daily question in summer] first time, second time, deal!
Leetcode1497- check whether array pairs can be divided by K - array - hash table - count
[daily question in summer] Luogu p5740 [deep foundation 7. Example 9] the best student