#include "mainwindow.h" #include "ui_mainwindow.h" #include <QRegExpValidator> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //ui->lineEdit->setInputMask("000.000.000.000;"); QRegExp exp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$"); QRegExpValidator *ipVal = new QRegExpValidator(exp); ui->lineEdit->setValidator(ipVal); } MainWindow::~MainWindow() { delete ui; }