QByteArray arr("Test QByteArray"); QString hexStr = arr.toHex();
QString hexStr = "5465737420517459496d6522436f6d706172657265"; QByteArray arr = QByteArray::fromHex(hexStr.toUtf8());This code takes a hexadecimal string, converts it to a QByteArray using the fromHex() method, and assigns the result to the arr variable. The resulting QByteArray contains the original binary data. Both of these examples use the QByteArray class, which is part of the Qt library.