Trying such a code:
int count = 0;
for(int j = p.length(); j > 0; j--)
{
if (p.at(j).isDigit()==true)
count++;
if (p.at(j).isDigit()==false)
break;
}
qDebug() << "count" << count;
QString p=le2->text();
int count = 0;
for(int j = p.length(); j > 0; j--)
{
if (p.at(j).isDigit()==true)
count++;
if (p.at(j).isDigit()==false)
break;
}
qDebug() << "count" << count;
To copy to clipboard, switch view to plain text mode
But get such an error: ASSERT: "i >= 0 && i < size()" in file ../../../../Qt/Desktop/Qt/473/gcc/include/QtCore/qstring.h, line 702
Can you help me and write what i am doing wrong? using p[j] gives no error but gives no result (count =0 in any case).
Bookmarks