//显示只能输入大小写字符,数字,特殊字符(特殊字符是全部列举出来的,键盘上还缺少[color=#FF0000] []\[/color] 三个字符不能输入,谁有办法请给我留言啊)
QRegExp regExp("[a-zA-Z0-9+=-!@#$%^&*(){}?>_|`~]{25}");
QRegExp onlyChinese("[\u4e00-\u9fa5]+$");
QRegExp ipExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)");//IP格式正则表达式,只能按照IP地址格式输入。
QRegExpValidator *ipValidator = new QRegExpValidator(ipExp, this);
ui->lineEdit_ip->setAttribute(Qt::WA_InputMethodEnabled, false);//设置不启用输入法
ui->lineEdit_ip->setValidator(ipValidator);