Is it permissible to mix serialization of data and readRawData/writeRawData to a QDataStream?
In other words, imagine I have information stored in a class that I'd like to transfer over the network using QDataStream, and imagine I have a pointer to that object:
myClass *myObject = new myClass;
myClass *myObject = new myClass;
To copy to clipboard, switch view to plain text mode
Would it be OK to do something like this:
... // assume 'out' is a QDataStream object.
out << (quint16)0; // Initialize "bytes of data" to 0
out.writeRawData((char *)myObject, myObject->sizeInBytes()); // put binary data into stream
out.device()->seek(0); // seek back to beginning of stream
out << (quint16)(out.size() - sizeof(quint16)); // set the "bytes of data"
... // assume 'out' is a QDataStream object.
out << (quint16)0; // Initialize "bytes of data" to 0
out.writeRawData((char *)myObject, myObject->sizeInBytes()); // put binary data into stream
out.device()->seek(0); // seek back to beginning of stream
out << (quint16)(out.size() - sizeof(quint16)); // set the "bytes of data"
To copy to clipboard, switch view to plain text mode
Or would it confuse Qt?
Same question for input of binary data using readRawData() ...
Thanks,
Gordon E.
Bookmarks