QRegExp rx("^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$");
QRegExpValidator *m_IP = new QRegExpValidator(rx, this);
lineEdit->setValidator(m_IP);
需包含QRegExpValidator头文件:
#include <QRegExpValidator>
QRegExp rx("^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$");
QRegExpValidator *m_IP = new QRegExpValidator(rx, this);
lineEdit->setValidator(m_IP);
需包含QRegExpValidator头文件:
#include <QRegExpValidator>