Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
How to use QIntValidator in Qt
The QIntValidator class provides a validation that ensures a string contains a valid integer within a specified range.
Values consisting of a number of digits equal to or less than the max value are considered intermediate.
The minimum and maximum values are set in one call with setRange(), or individually with setBottom() and setTop().
Note: val is object of QValidator.
- This property holds the validator's lowest acceptable value.
- This property holds the validator's highest acceptable value.
int main(int argc, char *argv)
QApplication a(argc, argv);
QWidget *win=new QWidget();
QLabel *lbl=new QLabel("QIntValidator");
QLineEdit *edit = new QLineEdit();
QValidator *val=new QIntValidator(1,10,edit);
QVBoxLayout *lay=new QVBoxLayout();
Note: From the above code validator we can write the integer value between 1 to 10.You can't write value more than 10.