April 2018
Beginner
714 pages
18h 21m
English
QString also provides some methods for convenient conversion between textual and numerical values. Methods such as toInt(), toDouble(), or toLongLong() make it easy to extract numerical values from strings. All such methods take an optional bool *ok parameter. If you pass a pointer to a bool variable as this parameter, the variable will be set to true or false, depending on whether the conversion was successful or not. Methods returning integers also take the second optional parameter that specifies the numerical base (for example, binary, octal, decimal, or hexadecimal) of the value:
bool ok; int v1 = QString("42").toInt(&ok, 10); // v1 = 42, ok = true long long v2 = QString("0xFFFFFF").toInt(&ok, 16); ...Read now
Unlock full access