[Qt-interest] I am facing a problem

Srdjan Todorovic todorovic.s at googlemail.com
Wed Aug 12 16:35:42 CEST 2009


Hi,

On 12/08/2009, Sujan Dasmahapatra <sujan.dasmahapatra at gmail.com> wrote:
> ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> int numberOfPoints = 201;
> QString testNumberOfPoints = QString::number(numberOfPoints);
>  for(i=0; i<testNumberOfPoints.length(); i++)
>         {
>                 qDebug() << testNumberOfPoints.at(i) << "\n";
>                 if(testNumberOfPoints.at(i) != '0' ||
> testNumberOfPoints.at(i) != '1' || testNumberOfPoints.at(i) != '2' ||
> testNumberOfPoints.at(i) != '3' ||
>                 testNumberOfPoints.at(i) != '4' ||  testNumberOfPoints.at(i)
> != '5' ||  testNumberOfPoints.at(i) != '6' || testNumberOfPoints.at(i) !=
> '7' ||
>                 testNumberOfPoints.at(i) != '8' || testNumberOfPoints.at(i)
> != '9')

You might get better performance if you did something like:

if ( testNumberOfPoints.at(i) < 48 || testNumberOfPoints.at(i) >58)
{
  // display warning
}

This would require that at() returns an int or a char (i've not
checked). But if you can somehow do an ASCII check, it may be faster.

Srdjan



More information about the Qt-interest-old mailing list