Wes Wes - 5 months ago 53
C++ Question

How to detect if a QString is made up of all numeric characters?

What do you guys think is the best way to tell if a QString is made up of just numbers?

There doesn't appear to be a convenience function in the QString library.

Do I have to iterate over every character, one at a time, or is there a more elegant way that I haven't thought of?

sth sth

You could use a regular expression, like this:

QRegExp re("\\d*");  // a digit (\d), zero or more times (*)
if (re.exactMatch(somestr))
   qDebug() << "all digits";