I am working on a project and I need to write (and in the future read) a string (QString) as binary. The string is in HEX format, like this "00010203040506070a0f01" etc...
I got this far through a tutorial on YouTube:
void Output()
{
QString ye("01020a");
QFile file("C:\\Users\\Public\\Documents\\Qt_Projects\\myfile.dat";
if(!file.open(QIODevice::WriteOnly))
{
qDebug() << "Could not open file to be written";
return;
}
QDataStream out(&file);
out.setVersion(QDataStream::Qt_5_0);
out << ye;
file.flush();
file.close();
}
But when I open "myfile.dat" with a hex editor, the hex values are different, the QString "ye" was written to the text side of things.
00 00 00 0C 00 30 00 31 00 30 00 32 00 30 00 61
Help?