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

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
  • 674
  • 2
  • 9
  • 21
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
  • 113
  • 7
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
  • 12
0
votes
2 answers

How to send QSqlQueryModel over QTcpSocket with QDatastream?

I want to send QSqlQueryModel to the another client with QDatastream and QTcpSocket. I want to remove some rows and add few extra rows to QSqlQueryModel (without changing the database) and send it to the client like this pseudocode:- QTcpSocket…
LightSith
  • 795
  • 12
  • 27
0
votes
1 answer

QDataStream not initialized while reading buffer from ipc fifo file descriptor

I want to communicate between two application using fifo (ipc), I have created a fifo by "mkfifo MyPipe" command. first App: .... .... fd = open("MyPipe", O_NONBLOCK | O_WRONLY); QByteArray buf; QDataStream…
Panahi
  • 1
  • 2
0
votes
2 answers

convert from 'const QVector>' to 'QVector>'

How can I solve the following, ie, converting const QVector> to QVector>? I tried a few steps but didn't help: QVector> points = const_cast>>(abc.points); abc.points is a struct…
Sayan Bera
  • 135
  • 2
  • 16
0
votes
1 answer

QT read/write from QDataStream

I think i am having a fundamental misunderstanding of how all of this works, I am trying to combine 2 hexfiles in my QDataStream and then output them to a new QFile. QFile filea( file1 ); QFile fileb( file2 ); QByteArray ba; QDataStream ds(ba); ds…
Aaron Manill
  • 41
  • 1
  • 7
0
votes
1 answer

Read binary file created in QT with QDataStream in C#

I'm trying to read an existing file that was created from a QT application using QDataStream, I'm using C# to read it but I can not make work. Here is my C# code for reading the file: I get no errors just a blank MessageBox. How can I read file…
fs_tigre
  • 10,650
  • 13
  • 73
  • 146
0
votes
0 answers

QTcpsocket/QTcpserver transmission, how to use QdataStream to transfer a table data

QTcpsocket/QTcpserver transmission, how to use QdataStream to transfer a table data?? There are ideas: Write data stream on each row and then call write(), but how to write again? Existing issues: Data is garbled, the first line of data is written…
0
votes
0 answers

Qt - Sending a large amount of data via QDataStream TCP

I want to benchmark a TCP Connection to an ECU (Transferrate) For that, i want so send some Data. The amout of data can be set in my GUI from x KB to x GB. The transferSize is calculated from the values set in the GUI. Buffer Size is 1024: #define…
0
votes
1 answer

QDataStream and sending & receiving structures over QTcpSocket

I am confused on how should I receive and send structures over a QTcp Socket. in.startTransaction(); QBytearray data; in >> data; if (!in.commitTransaction()) { qDebug() << "incomplete: " << data; return; } so say my packet looks like…
Sunfluxgames
  • 71
  • 1
  • 4
0
votes
0 answers

qt c++ send 6 bytes using tcp protocol

Hi everybody, first of all I'm new on network programming so maybe this is a simple question, but I don't get it. I try to send 6 Bytes to a microcontroller using tcp socket. In order to serialize my data I'm using qdatastream and qbytearray.…
0
votes
1 answer

QDataStream not working as expected

I am storing some data in QDataStream and immediately taking the data, but the count is showing zero while retriving. code looks fine but unexpected behaviour //Overloading QDataStream& operator<< (QDataStream& writeTO, const CascadeJobInfo&…
Sijith
  • 3,740
  • 17
  • 61
  • 101
0
votes
1 answer

Subclassing QIODevice: Wrapper for QUdpSocket

I am trying to implement my own wrapper over QUdpSocket because of it is uncomfortable to use. I can use it, but anyway I need to implement some intermediate buffer for access to QDataStream operations. In additional: I sublass QIODevice, header…
Vladimir Bershov
  • 2,701
  • 2
  • 21
  • 51
0
votes
1 answer

(De)serialization QSet with enum using QDataStream

I use Qt 4.8.7. I have enum Color {red, green, blue} and QSet. How should I (de)serialize QSet using QDataStream? Deserialization fails with custom type. Should I manually create serialization (loop over QSet elements) besides…
ilya
  • 1,103
  • 14
  • 36