Hex string convert back to QByteArray
-
I have used toHex to convert a QByteArray to a string for transmission in a string, at the other end I now need to do the reverse, is there a function to convert fromHex to a QByteArray?
Looking at: https://doc.qt.io/qt-5/qbytearray.html#fromHex
It looks like the documentation is wrong, because the only prototype I can see is:
QByteArray QByteArray::fromHex(const QByteArray &hexEncoded)Yet the example passes a string literal. I've tried:
QString strChunk(citChunk.value().toString()); QByteArray baChunk(QByteArray::fromHex(strChunk));
Compile error is:
C2664: 'QByteArray QByteArray::fromHex(const QByteArray &)': cannot convert argument 1 from 'QString' to 'const QByteArray &'
-
I have used toHex to convert a QByteArray to a string for transmission in a string, at the other end I now need to do the reverse, is there a function to convert fromHex to a QByteArray?
Looking at: https://doc.qt.io/qt-5/qbytearray.html#fromHex
It looks like the documentation is wrong, because the only prototype I can see is:
QByteArray QByteArray::fromHex(const QByteArray &hexEncoded)Yet the example passes a string literal. I've tried:
QString strChunk(citChunk.value().toString()); QByteArray baChunk(QByteArray::fromHex(strChunk));
Compile error is:
C2664: 'QByteArray QByteArray::fromHex(const QByteArray &)': cannot convert argument 1 from 'QString' to 'const QByteArray &'