QDataStream
does not write text, it writes binary data in the form specified here. So you should not expect to see any printable characters in the byte array, and certainly not the string representation of the number.
QTextStream
is used for writing out text, however it is not directly compatible with QVariant
. You would need to write your own code to test what type the variant contains and write out the appropriate string.