QT LineEdit控件IP地址正则判断



QString Octet = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";//数值大小


ui->lineEdit_ip->setValidator(new QRegExpValidator(QRegExp("^" + Octet + "\." + Octet + "\." + Octet + "\." + Octet + "$"), this));//ip正则


ui->lineEdit_port->setValidator(new QIntValidator(0,9999999,this));//只能输入整数,最大为9999999



分享

34.204.191.31