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.

105 questions
0
votes
1 answer

Read (many) values from QTcpSocket (fast)

I'm using a measurement device which sends (binary) float values using a tcp socket with up to 70 kHz. My goal is to read these values as fast as possible and use them in other parts of my program. Till now I'm able to extract value by value using a…
Famok
  • 3
  • 4
0
votes
1 answer

TGA reading header with QDataStream

I am trying to read a TGA file header with Qt QDataStream. I have the following structure from the specs with fixed types: #pragma pack(push, 1) /* TGA header */ struct tga_header_t { quint8 id_lenght; /* size of image id */ …
2A-66-42
  • 554
  • 1
  • 5
  • 18
0
votes
1 answer

Serialize shape to save and re-draw

I have a QGraphicsScene where I am drawing a QPainterPath, and I need to be able to save the shape, and redraw it when the app runs again. Here is how I'm drawing the shape, simplified version, and my write method. void drawPath(){ QPoint p1 =…
bauervision
  • 847
  • 2
  • 9
  • 25
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
  • 7,956
  • 5
  • 34
  • 61
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
  • 7,956
  • 5
  • 34
  • 61
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…
bgyooPtr
  • 163
  • 1
  • 10
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
  • 6
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

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,843
  • 2
  • 25
  • 42
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…
Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95
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,843
  • 2
  • 25
  • 42
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
  • 2,850
  • 9
  • 55
  • 103