[Qt-interest] Inconsistent toInt
Constantin Makshin
cmakshin at gmail.com
Wed Dec 30 15:18:51 CET 2009
It's the intended behavior — QByteArray::toInt() fails if "stopped at a
non-digit character after converting some digits" (a quote from a comment
in QLocalePrivate::bytearrayToLongLong() function that's used by
QByteArray::toInt()).
On Tue, 29 Dec 2009 07:34:51 +0300, Nikolay Moskvichev
<nikolay.moskvichev at gmail.com> wrote:
> Hello, i currently use Qt 4.6 and looks like there is inconsistent
> behaviour in toInt methods of QByteArray and QString.
>
> bool siccess;
> int res = QByteArray( "0001 " ).toInt(&siccess);
>
> Now res == 0, siccess == false.
>
> Next turn:
>
> int res = QString( "0001 " ).toInt(&siccess);
>
> Now res == 1, siccess == true.
>
> More ower:
>
> int res = QByteArray( " 0001" ).toInt(&siccess);
>
> Now res == 1, siccess == true.
>
> For me it looks like bug in QByteArray.toInt
--
Constantin Makshin
More information about the Qt-interest-old
mailing list