You can use regular expressions and QString::count
function:
QString str1("%1%2 test test %3 %4 %555");
int n = str1.count(QRegExp("%\\d+"));//n == 5
Update: Because QString's arg numbers can be in 1-99 range this reg-exp can be used:
QString str1("%1%2 test test %3 %4 %555");
int n = str1.count(QRegExp("%\\d{1,2}(?!\\d)"));//n == 4