[Qt-interest] QString::toInt

nandita-a.mehta at nokia.com nandita-a.mehta at nokia.com
Mon Sep 5 10:13:48 CEST 2011


Hi,

In the documentation http://doc.qt.nokia.com/latest/qstring.html#toInt ,it is mentioned

"If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used."

I understand from the above sentence that if the string begins with "0x" then base 16 is used implicitly while if the string begins with 0 base 8 is used implicitly.
However this is not the case.

QString str2 = "0xFF";
qDebug()<<str2.toInt(); //0 zero

QString str3 = "0789";
qDebug()<<str3.toInt(); //789


bool ok;

qDebug()<<str2.toInt(&ok, 16);//255


Any clarification what does above sentence mean?

Thanks,
Nandita

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110905/ee82deb9/attachment.html 


More information about the Qt-interest-old mailing list