[Qt-interest] how to extract the number from QString

Sean Harmer sean.harmer at maps-technology.com
Fri May 21 14:43:00 CEST 2010


On Friday 21 May 2010 13:33:39 hakiim the dream wrote:
> Hi all, suppose that I have the string abc001. I have to seperate the
> characters from the numeric part so that I have abc and 001
> seperated?Using QString::toInt() does not help to discriminate between a
> zero number and an alpha character since it returns both 0 for the alpha
> character and the integer 0.Thanks in advance.

Use QRegExp to capture the digits part of the string and use QString::toInt() 
on the captured string.

Sean



More information about the Qt-interest-old mailing list