Questions tagged [qdatastream]

The QDataStream class provides serialization of binary data to a QIODevice.

The QDataStream class provides serialization of binary data to a QIODevice.

A data stream is a binary stream of encoded information which is 100% independent of the host computer's operating system, CPU or byte order. For example, a data stream that is written by a PC under Windows can be read by a Sun SPARC running Solaris. One can also use a data stream to read/write raw unencoded binary data.

The QDataStream class implements the serialization of C++'s basic data types, like char, short, int, char *, etc. Serialization of more complex data is accomplished by breaking up the data into primitive units.

103 questions
1
vote
1 answer

Deserialized map's size increase in qt c++

I have serialized a map using QDataStream and written the object into a file. The serialized file size is 1.5mb when i deserialize it again and load the map into memory, the memory consumption was 300mb. I have used the same QDataStream to…
aditya
  • 21
  • 2
1
vote
1 answer

How to write bytes to a QDataStream in PySide and Python 3.X?

In the Qt documentation of QDataStream it says The QDataStream class provides serialization of binary data to a QIODevice. so that's what I want to do. I want to send bytes in PySide on Python 3.X to a QDataStream. writeRawData however expects…
Trilarion
  • 9,318
  • 9
  • 55
  • 91
1
vote
2 answers

Qt - QDataStream with overloaded operator<< for object pointer (Class*)

I am trying to read/write my custom classes using QDataStream. I have overridden the << and >> operators, which seem to work fine for normal objects. However, when I try to pass a pointer to my custom object, the overridden operators don't work…
Elessar
  • 45
  • 1
  • 2
  • 10
0
votes
0 answers

Where should we close the file when using a QFile with a QDataStream?

I'm writing into a QFile using a QDataStream (like in the following example): QFile file(m_fileName); bool rc = file.open(QIODevice::ReadOnly | QIODevice::Truncate | QIODevice::Text); QDataStream out(file); out << *... lots of interesting things…
0
votes
0 answers

Reconstructing a QSqlQuery after serialization

I am trying to pass PSQL queries from the front end to the backend, where they are run and the results returned to the front end. I understand how to break down the QSqlQuery on the backend and send it to the frontend with a QDataStream (will do…
grademacher
  • 65
  • 3
  • 8
0
votes
0 answers

Passing QDataStream object to another method (copy constructor vs stateful)

While implementing a generic drag drop model, I arrived at the following question. When encoding mimeData, I want to write the origin row and column of dragged indexes into the data stream. The serialization of the item data depends on the…
hdmjt
  • 15
  • 3
0
votes
0 answers

Converting littleEndian via QDataStream

i want to send some integers (int32_t) via network. For this I convert the integers first and send them. p.x = 129; p.y = 42; p.d = counter++; converted[0] = htonl(p.x); converted[1] = htonl(p.y); converted[2] = htonl(p.d); if ( (bytes =…
0
votes
0 answers

Connecting one QDataStream to another

I currently stream data from MyClass to a QFile and it works great. I now want to insert an encryption (just invert the bits) step between my MyClass and QFile. I'm not sure how to approach this. Do I create a new object (MyENc) descendant from…
TSG
  • 3,545
  • 8
  • 45
  • 101
0
votes
1 answer

Can't define friend functions without namespace conflict

I have created a class (MyNodeClass) and now want to add serialization capabilities. I declare (in mynodeclass.h) my serialization methods as follows: #ifndef MYNODECLASS_H #define MYNODECLASS_H #include #include #include…
TSG
  • 3,545
  • 8
  • 45
  • 101
0
votes
0 answers

Serialize / Deserialize QVariantMap with QDataStream between PyQt >> Qt-C++

I can Successfully Serialize / Deserialize QVariantMap through QDataStream in the PyQt5 Python : data = {'mq_username': ('123'), 'np_database': ('png') , 'category': ('png') , 'enroll_name': ('png') , 'notes': ('png') , 'file': ('png') , …
Prometheus
  • 75
  • 2
  • 7
0
votes
1 answer

QDataStream readQString() How to read utf8 String

I am trying to decode UDP packet data from an application which encoded the data using Qt's QDataStream methods, but having trouble when trying to decode string fields. The docs say the data was encoded in utf8. The python QDataStream module only…
0
votes
1 answer

Convert Union to QByteArray and vice-versa using QUdpSocket in Qt

I have one Union like below #define no_of_bits 240 #define word_size 16 struct bits { unsigned short int bit1:1; unsigned short int bit2:1; unsigned short int bit3:1; unsigned short int bit4:1; unsigned short int bit5:1; …
Vinay Kumar
  • 308
  • 1
  • 7
0
votes
1 answer

Converting QImage to QByteArray using QDataStream

Im trying to convert a QImage that maked from ScreenShot to a QByteArray for sending via QTCPSocket. when i convert QImage to QByteArray and before sending it i try to deserialize and show it on label it cant ! what's my mistake? thx for…
H.M
  • 43
  • 8
0
votes
1 answer

Why QDatastream is not giving the correct output

In the given code i am first inserting 1 number in the stream and than i am putting that value in a test named Variable. when i print the variable i get the output as 0 instead of 1. This is the code. QByteArray data; QDataStream…
suman
  • 83
  • 6
0
votes
1 answer

Reading specific object in QDataStream and count number of objects stored

I am writting some objects in a binary file and I would like to read them back. To explain you what I am trying to do, I prepared a simple example with a class User that contains the QString name and QList name of childrens. Please see the code…
froz
  • 163
  • 1
  • 8