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
2 answers

Saving a QImage to QBuffer

I am doing something like this: QImage image(width, height, QImage::Format_RGB32); frame.fill(QColor(255, 255, 255).rgb()); QBuffer buffer; buffer.open(QBuffer::ReadWrite); QDataStream out(&buffer); Option 1: out << image; Option…
surana4u
  • 31
  • 3
0
votes
1 answer

QDataStream allocation between members

class ReadFile { public: void init(); QList getData(); private: QFile file; QDataStream read; double bufferFloat; quint32 bufferInteger } The idea is now that when init() is called, the a file should be opened…
casparjespersen
  • 2,662
  • 4
  • 32
  • 44
0
votes
1 answer

QDataStream unable to serialize data

I am trying to follow the tutorial here and serialize Qt objects. Here is my code: QFile file("/Users/kaustav/Desktop/boo.dat"); if (!file.open(QIODevice::WriteOnly)) { qDebug() << "Cannot open file for writing: " <<…
SexyBeast
  • 8,635
  • 25
  • 92
  • 179
0
votes
0 answers

QDataStream and byte order in Big Endian

I have a program which sends images over the network. I manually create pixels (using QRgb class) and I insert them into QDataStream. It is quite easy when there are 16 or 32 bits per pixel (I can insert quint16 or quint32), but in RGB888 (24 bits…
trivelt
  • 1,643
  • 2
  • 17
  • 39
0
votes
2 answers

saving and loading vector Qt & OpenCV

I'm working on face recognition in Qt & openCV using the FisherFaces recognizer which doesn't support updating so i have to save the faces database to retrain the recognizer after any changes. Here is my code for saving : save(const…
Chebhou
  • 138
  • 14
0
votes
2 answers

Can't read QList from a file

I have a problem with stream operator>>. I'm trying to save and load on file a QList of custom objects. The save routine seems working fine but reading the file causes a crash. I prepared a very minimal example. First of all the custom class: class…
bullet
  • 57
  • 7
0
votes
1 answer

Qt QTcpSocket streaming

My application sent object to the server via QTcpSocket. Client: void client::sendFile(QString path) { QFile toSend(path); QByteArray rawFile; rawFile = toSend.readAll(); QDataStream out(cl); out >> rawFile; } Server: void…
WildDev
  • 1,970
  • 4
  • 27
  • 60
0
votes
1 answer

How to save a datastream in mp3 format?

I am receiving an mp3 file in packets over network and want to save them in mp3 format on my computer. I am programming in C++ and using Qt Creator as IDE. To be more specific, I am storing the received data in a QDataStream object which is…
OnurA
  • 541
  • 9
  • 23
0
votes
3 answers

Save and load QList to file

I have a class ContactData and a class FriendList holding a QList and I overloaded the << / >> operators. contactdata.h class ContactData { //all public for testing public: ContactData(); QString m_name; QString m_description; bool…
Dunkelbunt27
  • 127
  • 3
  • 11
-1
votes
2 answers

How to initialize a child class from a pointer on its abstract mother class?

So I'm new to C++, and my problem is this one: I have an abstract class, which as multiple child classes (and they had other child classes too). I am trying to use polymorphism to serialize and deserialize these child classes, and have, in my…
trablazar
  • 11
  • 3
-1
votes
1 answer

QDataStream not working as well and return error with reusing

I am storing some data in QDataStream and immediately taking the data bool M_FILEMANAGER::readFromDataFile(QString& fileName,RADARBEAMPATTERN *radbeam) { // for reading from file sequence ..... QFile fin(m_folderPath +"/"+ fileName); if…
-1
votes
1 answer

I want to view the original Image

I want to view the original Image file. But all Images are converted into the spotted,corrupted image. It seems that the previous image is not equal to the behind image. Please change the image size in the QImage's constructor into your arbitrary…
Haru
  • 1,491
  • 1
  • 9
  • 23
-1
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
  • 51
  • 1
  • 3
1 2 3 4 5 6
7