当前位置:网站首页>Vérification simple de la lecture et de l'écriture de qdatastream
Vérification simple de la lecture et de l'écriture de qdatastream
2022-07-01 05:06:00 【Otek Glodon.】
Le but est d'écrire des binaires et de lire du contenu:
#include <QApplication>
#include <QFile>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFile aFile1("file.dat");
if (!(aFile1.open(QIODevice::WriteOnly)))//Ouvrir le fichier en écriture seulement
return -1;
QDataStream bStream(&aFile1);
bStream.setVersion(QDataStream::Qt_5_9);
//Écrire à tour de rôle la taille totale de l'espace d'information,Nom du fichier taille de l'espace d'information,Nom du fichier
QString currentFileName = "abcdFile" ;
qint64 v1 = 0,v2 = 0;
bStream << qint64(v1) << qint64(v2) << currentFileName;
//Le curseur retourne au début du fichierqint64Modifier
bStream.device()->seek(0);
v1 = 13548,v2 = 8;
bStream<< qint64(v1) << qint64(v2);
// Cette étape consiste à rafraîchir le fichier , Pour que les documents écrits prennent effet
aFile1.flush();
aFile1.close();
// LiredatDocumentation
QFile aFile2("file.dat");
if (!(aFile2.open(QIODevice::ReadOnly)))//Ouvrir le fichier en écriture seulement
return -1;
QDataStream aStream(&aFile2);
aStream.setVersion(QDataStream::Qt_5_9);
qint64 v3 = 0,v4 = 0;
aStream >> v3 >> v4 >> currentFileName;//Lire les données,DépôttemEtstr
qDebug() << v3 << v4 << currentFileName ;// Imprimer pour voir les résultats
aFile2.close();
return a.exec();
}
边栏推荐
- Solve the problem that the external chain file of Qiankun sub application cannot be obtained
- Global and Chinese market of protection circuit modules 2022-2028: Research Report on technology, participants, trends, market size and share
- Solution: thread 1:[< *> setvalue:forundefined key]: this class is not key value coding compliant for the key*
- Common methods in transforms
- [hard ten treasures] - 1 [basic knowledge] classification of power supply
- 【暑期每日一题】洛谷 P2637 第一次,第二次,成交!
- 无器械健身
- LeetCode_66(加一)
- 点赞的云函数
- Distributed architecture system splitting principles, requirements and microservice splitting steps
猜你喜欢

How to traverse massive data in redis

【暑期每日一题】洛谷 P5886 Hello, 2020!

Copier le matériel de conseils de bébé ne peut pas être vide, comment résoudre?

LeetCode1497-检查数组对是否可以被 k 整除-数组-哈希表-计数

解决:拖动xib控件到代码文件中,报错setValue:forUndefinedKey:this class is not key value coding-compliant for the key

Daily question -leetcode1175- permutation of prime numbers - Mathematics

分布式数据库数据一致性的原理、与技术实现方案

Tcp/ip explanation (version 2) notes / 3 link layer / 3.2 Ethernet and IEEE 802 lan/man standards

STM32 extended key scan

Fitness without equipment
随机推荐
LeetCode_35(搜索插入位置)
Leetcode522- longest special sequence ii- hash table - String - double pointer
LeetCode_ 28 (implement strstr())
Pico neo3 handle grabs objects
智慧运维:基于 BIM 技术的可视化管理系统
LeetCode_ 35 (search insertion position)
Pytorch neural network construction template
【FTP】FTP常用命令,持续更新中……
The longest increasing subsequence and its optimal solution, total animal weight problem
Programmers dig "holes" to get rich: if they find a loophole, they will be rewarded 12.72 million yuan
Global and Chinese market of metal oxide semiconductor field effect transistors 2022-2028: Research Report on technology, participants, trends, market size and share
How to traverse massive data in redis
线程类的几大创建方法
How to start learning editing? Detailed analysis of zero basis
Tcp/ip explanation (version 2) notes / 3 link layer / 3.2 Ethernet and IEEE 802 lan/man standards
FileInputStream
Global and Chinese markets of superconductor 2022-2028: Research Report on technology, participants, trends, market size and share
Thoughts on the construction of Meizhou cell room
Pytorch convolution operation
LeetCode1497-检查数组对是否可以被 k 整除-数组-哈希表-计数