How to Restrict Input Content in QLineEdit in Qt
How to Restrict Input Content in QLineEdit in Qt
Only allow input of integers:
lineEdit->setValidator(new QIntValidator(lineEdit));
Only allow input of numbers:
lineEdit->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
Only allow input of letters and numbers:
lineEdit->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$")));
Only allow input of uppercase data:
lineEdit->setValidator(new QRegExpValidator(QRegExp("^[A-Z]+$")));
Only allow input of lowercase data:
lineEdit->setValidator(new QRegExpValidator(QRegExp("^[a-z]+$")));
Only allow input of letters:
lineEdit->setValidator(new QRegExpValidator(QRegExp("^[A-Za-z]+$")));