QByteArray toInt doesnt work
-
There is my code under debug.

Conversion to int doesn't work. I get 0 in the current_time variable but the conversion result is success (ok=0)
Compilation is correct.
Any sugestion? -
There is my code under debug.

Conversion to int doesn't work. I get 0 in the current_time variable but the conversion result is success (ok=0)
Compilation is correct.
Any sugestion?@BartoszT
Naturally we can assumeQByteArray::toInt()does work, else there would be a whole lot of problems & complaints.In what way is your
QByteArray CurrentDataTimecontents related to the number of seconds (since 1970) argument inQDateTime::fromTime_t(uint seconds)? (And while I think of it, are you compiling for 32-, not 64-bit?) -

and has 4 bytes - it is 32bit time.... but now i see that ok get a false as a result of conversion toInt.
So, why toInt doesnt watn to work whit this 4byte QByteArray?@BartoszT said in QByteArray toInt doesnt work:
So, why toInt doesnt watn to work whit this 4byte QByteArray?
Because your byte array does not contain ASCII text that represents an integer. See https://doc.qt.io/qt-5/qbytearray.html#toInt for an example on how to use
QByteArray::toInt().If you want to interpret 4 bytes as a 32-bit integer, use a
reinterpret_cast:int i = *reinterpret_cast<const int*>(myArray.constData());