QByteArray to QString

You can use QTextCodec to convert the bytearray to a string: (1015 is UTF-16, 1014 UTF-16LE, 1013 UTF-16BE, 106 UTF-8) From your example we can see that the string “test” is encoded as “t\0 e\0 s\0 t\0 \0 \0” in your encoding, i.e. every ascii character is followed by a \0-byte, or resp. every ascii character is encoded as 2 bytes. The … Read more

How to change string into QString?

If by string you mean std::string you can do it with this method: QString QString::fromStdString(const std::string & str) If by string you mean Ascii encoded const char * then you can use this method: QString QString::fromAscii(const char * str, int size = -1) If you have const char * encoded with system encoding that can be read with QTextCodec::codecForLocale() then you should use … Read more