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
0
votes
0 answers

How can I send pointer members of a class through a QDataStream?

I have a user-defined class, say, MyClass. Suppose its definition is as follows: class MyClass { int a; int *b; Base *c; }; where I have class Base { int base_data; public: Base(int) { //implementation } virtual…
GoodDeeds
  • 5,837
  • 4
  • 28
  • 51
0
votes
1 answer

How do I read a class object from a QTcpSocket using a QDataStream?

I have a class defined by me, say MyClass. I would like to send an object of this class through a QTcpSocket. This answer suggests using a QDataStream, and this shows how the << and >> operators can be overloaded to achieve this. I have so far…
GoodDeeds
  • 5,837
  • 4
  • 28
  • 51
0
votes
2 answers

Write/Read bit fields structure to/from file

I am trying to write bit fields structure to file and then read it. For example: typedef struct{ ushort a:4, b:4, c:4, d:4; } teststruct; I try to write and read it like…
0
votes
1 answer

Qt QSharedMemory and QDataStream

I want to make shared memory using QSharedMemory. So, I am trying to read/write my custom classes using QDataStream. But I do not know how to override double pointer(float **). (The reason I use double pointers is because of opencv cv::Mat, If there…
user6445248
  • 133
  • 1
  • 9
0
votes
2 answers

writing 00001010 to Qfile adds another Byte in front

I am programming a tool in Qt in which I want to write binary data into a file. Everything works fine except when I am trying to write the decimal value '10' (0000 1010 in binary) into the file. in this case I get an additional byte with the value…
Mech Mobo
  • 3
  • 1
0
votes
1 answer

QDataStream is becoming Readonly

I have two classes named IPCBase and DispatchData. Now I want to pass QDataStrean Object drom IPCBase to DispatchData. First I tried to send it directly using Connect Statement. But it is giving error like QDataStream object is not registered in…
Umang Modi
  • 11
  • 5
0
votes
0 answers

Sending UDP datagrams using QUdpSocket and QDatastream

The program is able to send .txt files. But any other filetype gets corrupted. I think it has something to do with the datatypes I store my frames in. Sorry for the long post i just have no idea where my problem might be. I'm new to QT as well as…
0
votes
1 answer

Correct overriding QDataStream operators and linking problems

I need override >> and << operators of QDataStream. There's my code: QDataStream &operator <<(QDataStream &out, const SScenarioEntry Entry) { out.writeRawData(Entry.EntryName, sizeof(Entry.EntryName)); out << Entry.Number; out <<…
0
votes
1 answer

Tuning QDataStream

I have a program that in outline processes binary data from afile. Code outline is the following: QFile fileIn ("the_file"); fileIn.open(QIODevice::ReadOnly); The file has a mix of binary and text data. The file contents are read using…
TenG
  • 3,429
  • 2
  • 22
  • 36
0
votes
0 answers

How to pass QDataStream as parameter to signal in Qt5

I am writing a method to parse a network packet in the form of a QByteArray. It will extract a few values using QDataStream and then hopefully pass the QDataStream along to another method for further processing (to avoid the overhead of making…
Lennart Rolland
  • 7,561
  • 6
  • 47
  • 80
0
votes
1 answer

Read QDateTime from QDataStream giving null

I have the following region of data being read into a QDataStream object : DE 07 05 19 0E 28 1A This should translate to the date/time: 25-05-2014 15:40:26 I am trying to use the following to read this into a QDateTime variable: QFile…
TenG
  • 3,429
  • 2
  • 22
  • 36
0
votes
1 answer

Data read from file takes way more memory than file size

I've written some data into a file the following way: result = new QHash, QVector >; QFile resfile("result.txt"); resfile.open(QIODevice::WriteOnly | QIODevice::Append); QDataStream out(&resfile); while(condition) { QString…
0
votes
1 answer

How to serialize a QHash and a QMap in a single file?

I have a QHash and a seperate QMap. I can serialize them alone. But I would like to serilize them in a single file: QMap myMap; QHash myHash; // .. fill: both have 4 (key,value) pairs. // write here QDataStream out…
Ralf Wickum
  • 1,300
  • 5
  • 34
  • 66
0
votes
3 answers

Serializing QHash with own Class?

I have a QHash , whereas MyClass is just a collection of some QString quint8 values with getters and setters. MyClass also has a QDataStream &operator<<(QDataStream &ds, const MyClass &obj) overwritten, there. To serialize…
Ralf Wickum
  • 1,300
  • 5
  • 34
  • 66
0
votes
1 answer

How to use structured QDataStream and Serialization?

I have a CSS like data structure like in this example: /* CSS like style sheet file *.pss */ @include "otherStyleSheet.pss"; /* comment */ [propertyID="72100000"] { fillColor : #f3f1ed; minSize : 5; lineWidth : 3; } /* sphere */…
Ralf Wickum
  • 1,300
  • 5
  • 34
  • 66