Note that QByteArray is using a signed char* buffer, so you get a truncation for 0xAB and so on (max value is 127, hex 0x7F).

As for your second question, use QString and arg:
Qt Code:
  1. for (int m=0;m<7;m++)
  2. qDebug() << hex << QString("%0").arg(test.at(m), 2, 16, QChar('0'));
To copy to clipboard, switch view to plain text mode