Please nominate your Qt Champions for 2021!

Am I misunderstanding or misusing QByteArray::toHex()?

  • I have a

    char[32] data;

    populated with some data and its bytes increment from 0x00 to 0xff one after another over the course of the algorithm. When I call

    auto hex = QByteArray(data).toHex();

    every time hex contains an empty array regardless of the increments of data bytes.

    What's the trick?

  • Moderators

    If first element in data is 0x00 then QByteArray(data) will be empty (it assumes a null terminated string). Pass the size as a second parameter.

Log in to reply