i write a test program whit QDatastream
read and write the binary file
but
it's different
my code
Qt Code:
out << file.readAll();To copy to clipboard, switch view to plain text mode
diff 1.png 2
output:
Binary files 1.png and 2 differ
why ?
i write a test program whit QDatastream
read and write the binary file
but
it's different
my code
Qt Code:
out << file.readAll();To copy to clipboard, switch view to plain text mode
diff 1.png 2
output:
Binary files 1.png and 2 differ
why ?
Last edited by Lykurg; 2nd November 2010 at 06:21. Reason: changed [qtclass] to [code]
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.
what you have said is very helpful, thank you very much, ChrisW67.
Bookmarks