QValidator is a better way than input mask. There are currently 3 validators prepared in Qt: QDoubleValidator, QIntValidator, QRegExpValidator.
If you want to validate as the input string is an int you can do it like this (from Qt Assistant):
// the edit lineedit will only accept integers between 100 and 999
edit->setValidator(validator);
QValidator *validator = new QIntValidator(100, 999, this);
QLineEdit *edit = new QLineEdit(this);
// the edit lineedit will only accept integers between 100 and 999
edit->setValidator(validator);
To copy to clipboard, switch view to plain text mode
If you want some reg exp validating than:
edit->setValidator(validator);
QRegExp rx("[1-9]\\d{0,3}");
QValidator *validator = new QRegExpValidator(rx, this);
QLineEdit *edit = new QLineEdit(this);
edit->setValidator(validator);
To copy to clipboard, switch view to plain text mode
will allow you to input numbers between 1 and 9999;
Bookmarks