Qt QRegExpValidator内置检验器

这样一行代码:

QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
lineEdit->setValidator(new QRegExpValidator(regExp, this));

QRegExpValidator带一个正则表达式“[A-Za-z][1-9][0-9]{0,2}”,意思是:允许一个大写或者小写的字母,后面跟着一个范围为1~9的数字,后面再跟0个、1个或2个0~9的数字。(对于正则表达式的介绍,请查看参考文档中的QRegExp)

你可能感兴趣的:(2.,C++,GUI,QT4)