Etienne Sandré-Chardonnal
2017-02-09 17:18:07 UTC
Dear all,
I just found out a bug in my code which was due to the way I wrote/read
from QDataStream.
I write a string like that in one program, from a std::string. This uses
the null-terminated char* overload of << :
std::string str("test");
stream << str.c_str();
I read the data like that in another program:
QByteArray ba;
stream >> ba;
Then ba.size() returns 5 and it contains the null character. Therefore,
comparing it to "test" failed.
In the documentation I cannot find a QByteArray & overload of operator >>.
QByteArray is not supposed to be castable to char*. What is happening here?
Thanks for your help!
Best regards,
Etienne
I just found out a bug in my code which was due to the way I wrote/read
from QDataStream.
I write a string like that in one program, from a std::string. This uses
the null-terminated char* overload of << :
std::string str("test");
stream << str.c_str();
I read the data like that in another program:
QByteArray ba;
stream >> ba;
Then ba.size() returns 5 and it contains the null character. Therefore,
comparing it to "test" failed.
In the documentation I cannot find a QByteArray & overload of operator >>.
QByteArray is not supposed to be castable to char*. What is happening here?
Thanks for your help!
Best regards,
Etienne