1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <QRegExp>
#include <QRegExpValidator>

bool IsValidPhoneNumber(const QString & phoneNum)
{
QRegExp regx("^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$");
QRegExpValidator regs(regx, 0);
QString pNum = phoneNum;
int pos = 0;
QValidator::State res = regs.validate(pNum, pos);
if (QValidator::Acceptable == res) {
return true;
}
else {
return false;
}
}