There is a QString , you need to check whether it is a number. In QChar there is an isNumber() method that does this, but it does not exist in QString . I think to go through each character, checking it, but maybe there is a better solution.
If there is one, please tell me.
1 answer
int QString::toInt(bool *ok = Q_NULLPTR, int base = 10) const
long QString::toLong(bool *ok = Q_NULLPTR, int base = 10) const
If you simply check that all the characters in the string are numbers, or the desired "mask", then it is better to use regulars :
bool QString::contains(const QRegExp &rx) const
- I will add only that for actually checking the number of whether this line uses the
bool *okparameter for "similar" functions (you can addtoDoubleandtoFloatto the specifiedtoFloat). - asianirish
|
strto...orsto..and see if something is left unread? - HarryQStringto char * are needed. And there is little point in this, because QString can do everything by itself) - Majestioint- the first option in my answer. - Majestio