QByteArray stores wrong value;

i have this code

 
  QByteArray id = "\x98\x33\xB5\x14";


the problem is when i qDebug() id it show that the contents is

 
  "\x98""3\xB5\x14"


any way to solve this problem? am i missing something?

thank you
you haven't shared the full implementation of datatype QByteArray but if it were (akin to) std::string we'd need some escape characters:
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <string>

int main()
{
    std::string id = "\\x98\\x33\\xB5\\x14";
    std::cout << id << "\n";
    std::cout << id.size() << "\n";
}
Last edited on
@gunnerfunner
QByteArray is a Qt class. http://doc.qt.io/qt-5/qbytearray-members.html
It is not the wrong value. Read the documentation for QDebug::operator<<(const QByteArray&).
http://doc.qt.io/qt-5/qdebug.html#operator-lt-lt-19
Topic archived. No new replies allowed.