i write a test program whit QDatastream read and write the binary file but it's dif
i write a test program whit QDatastream
read and write the binary file
but
it's different
my code
Code:
out << file.readAll();
diff 1.png 2
output:
Binary files 1.png and 2 differ
why ?
Re: i write a test program whit QDatastream read and write the binary file but it's
They differ because a QDataStream is not a raw byte stream. You call QIODevice::readAll(), which returns a QByteArray, and then ask QDataStream to serialise the QByteArray to a stream. QDataStream will output sufficient information to reconstruct the QByteArray, including any internal structures, by reading from QDataStream later on any platform. You really just want the base QIODevice methods to read and write raw bytes.
If you just want to copy a file then QFile::copy() will be of interest.
Re: i write a test program whit QDatastream read and write the binary file but it's
what you have said is very helpful, thank you very much, ChrisW67.