I have a LineEdit and want to convert the value to qint64 (long) for some calculation. But I always get a problem and the value return 0. How can I solve it?
Printable View
I have a LineEdit and want to convert the value to qint64 (long) for some calculation. But I always get a problem and the value return 0. How can I solve it?
If you want a qint64 you should call QString::toLongLong().
long has the problem that on Windows, or at least the Microsoft C++ compiler, a long is only 4 bytes, basically equivalent of an int.
Cheers,
_
Well, yes, 20.5 is not an integer so you get zero and the ok flag set to false. If you need to accept floating point numbers then you need to convert to a double and then apply whatever rounding is appropriate.
20.5 is not an integer value, it contains a .
Instead this is a floating point value, so have a look at QString::toDouble()
Cheers,
_