当前位置:网站首页>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();
}
边栏推荐
- [daily question in summer] function of rogu p3742 UMI
- LeetCode_ 66 (plus one)
- 科研狗可能需要的一些工具
- Global and Chinese market of broadband amplifiers 2022-2028: Research Report on technology, participants, trends, market size and share
- Pytoch (I) -- basic grammar
- Leetcode522- longest special sequence ii- hash table - String - double pointer
- [daily question in summer] Luogu p7222 [rc-04] informatics competition
- Programmers dig "holes" to get rich: if they find a loophole, they will be rewarded 12.72 million yuan
- Fitness without equipment
- Tcp/ip explanation (version 2) notes / 3 link layer / 3.2 Ethernet and IEEE 802 lan/man standards
猜你喜欢

Fitness without equipment

Principle, technology and implementation scheme of data consistency in distributed database

分布式全局唯一ID解决方案详解

Leetcode316- remove duplicate letters - stack - greedy - string

无器械健身

Pytoch (II) -- activation function, loss function and its gradient

Technology sharing | broadcast function design in integrated dispatching
![解决:Thread 1:[<*>setValue:forUndefinedKey]:this class is not key value coding-compliant for the key *](/img/88/0b99d1db2cdc70ab72d2b3c623dfaa.jpg)
解决:Thread 1:[<*>setValue:forUndefinedKey]:this class is not key value coding-compliant for the key *

STM32扩展板 数码管显示

导电滑环使用的注意事项
随机推荐
【暑期每日一题】洛谷 P7222 [RC-04] 信息学竞赛
洗个冷水澡吧
Global and Chinese market of protection circuit modules 2022-2028: Research Report on technology, participants, trends, market size and share
分布式锁的实现
Copy baby prompt: material cannot be empty. How to solve it?
Global and Chinese market of 3D design and modeling software 2022-2028: Research Report on technology, participants, trends, market size and share
Thread safety issues
[NLP Li Hongyi] notes
Manually implement a simple stack
LeetCode_ 28 (implement strstr())
Construction of Meizhou nursing laboratory: equipment configuration
Leetcode316- remove duplicate letters - stack - greedy - string
PR 2021 quick start tutorial, learn about the and functions of the timeline panel
Like cloud functions
Copier le matériel de conseils de bébé ne peut pas être vide, comment résoudre?
Pytorch neural network construction template
[FTP] the solution to "227 entering passive mode" during FTP connection
Design experience of Meizhou clinical laboratory
Global and Chinese market of high-end home theater 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market for instant messaging security and compliance solutions 2022-2028: Research Report on technology, participants, trends, market size and share