QRegExp regx("^[0-9]$|^[0-9]{2}$|^[1][0-9]{2}$|^[2][0-4][0-9]$|^[2][5][0-5]$"); ui.FreLine->setValidator(new QRegExpValidator(regx));