this->line_ip = new QLineEdit(this);
QString str = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5] | 2[0 - 4][0 - 9] | [01] ? [0 - 9][0 - 9] ? )\\b";
this->line_ip->setValidator(new QRegExpValidator(QRegExp(str)));
this->line_ip->setInputMask("0000.000.000.000");
设置格式限定后