当前位置:网站首页>QT serialization qdatastream
QT serialization qdatastream
2022-07-28 14:51:00 【Love the west wind】
Communication data serialization of all platforms , Every language will encounter QT As a cross platform language , Comparison has also done a good job ;
QDataStream to glance at API , Meeting << ,>> Overloaded , You can format native data types , Such as QString int;
QDataStream::QDataStream(QIODevice * d)
template <typename T>
inline QDataStream & operator<<(QDataStream & s, const QList<T> & l)
template <typename T>
inline QDataStream & operator>>(QDataStream & s, QList<T> & l)Use samples :
write in :
QByteArray outBlock;
QDataStream sendout(&outBlock,QIODevice::WriteOnly);
int totalBytes = 30;
QString type = "name";
OffSetArray offset;
offset.pt1 =0.1;
offset.pt2 =0.2;
offset.pt3 =0.3;
offset.pt4 =0.4;
QByteArray data;//=offset;
data.append((char*)&offset,sizeof (OffSetArray));
sendout<<totalBytes<<uchar(0) <<type<<data; // read
int total ;
QString name = "";
QByteArray tmp;
sendout>>totalBytes>>name>>tmp;
OffSetArray *pTest = (OffSetArray*)tmp.data();
QString str = QString("%1,%2,%3,%4").arg(pTest->pt1).arg(pTest->pt2).arg(pTest->pt3).arg(pTest->pt4);
qDebug() << "pt --"<<str;Of course , It can be serialized directly , Structure , But it needs to be realized by yourself , I prefer to switch according to the type ;
边栏推荐
- Iterator iterator interface
- Redis-Redis在Jedis中的使用
- 468产品策划与推广方案(150份)
- Swiftui layout - alignment
- 2022 safety officer-a certificate operation certificate examination question bank simulated examination platform operation
- C语言库函数getchar()怎么使用
- [leetcode] 1331. Array sequence number conversion
- Animation mechanism of swiftui
- Qtableview in QT sets three methods of paging display [easy to understand]
- Swiftui layout - size (bottom)
猜你喜欢

国产数据库的红利还能“吃”多久?

Langjing Technology (Trax China) "robot +ai" opens the era of Chinese retail meta universe

UI开发中所遇到的各种坑

58子站安居,经纪人营销管理平台登录接口加密逆向

2022 low voltage electrician examination questions and answers

linux安装redis
C # 7 methods to obtain the current path

Redis redis use in jedis
![[ecmascript6] other new interface features](/img/da/377f93d83b6722bf250d270e4eea28.png)
[ecmascript6] other new interface features

围绕新市民金融聚焦差异化产品设计、智能技术提效及素养教育
随机推荐
C language program: judging triangles
9、 Uni popup usage popup effect at the bottom of the drop-down box
On July 29, apachecon | apachepulsar's exploration and practice in vivo will be broadcast soon
Raspberry pie foundation | summarize and record some operations in the learning process of raspberry pie
SwiftUI 布局 —— 对齐
JS instantiation method
OKR与GRAD
The second pre class exercise
Use of formdata object, VAR formdata=new formdata()
How to make the characters in the photos laugh? HMS core video editing service one click smile function makes people smile more naturally
Excel VBA 开发过程中遇到的一些问题,解决方案,持续更新
Ability to add class @published for custom attribute wrapper types
【LeetCode】 贴纸拼词(动态规划)
How to perform batch operations in core data
Read the introduction tutorial of rainbow
C # 7 methods to obtain the current path
Store and guarantee rancher data based on Minio objects
Excel VBA password free view VBE encryption code
Core Data 是如何在 SQLite 中保存数据的
468 product planning and promotion plan (150 copies)