How to read a Number from the QByteArray
Hi,
I'm trying to get a integer from a QByteArray.
After scaning the documentation I would say that the fowlloing piece of code should work:
-----------
int ntime;
QByteArray stderr1 ("10");
QBuffer buffer(&stderr1);
buffer.open(QIODevice::ReadOnly);
QDataStream in(&buffer);
in >> ntime;
printf("Output value %d\n",ntime);
-------------
I would expect the output :
Output value 10
but the Output is instead:
Output value 0
what am I doing wrong?:confused:
best regards
António Tomé
Re: How to read a Number from the QByteArray
QDataStream uses its own, binary format. Use QTextStream instead:
Code:
int ntime;
in >> ntime;
printf("Output value %d\n",ntime);
Re: How to read a Number from the QByteArray
Many thanks,
It worked flawless.
António Tomé