| ID | ... | Creation date | 20 April 2009 |
| Platform | S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition | Tested on devices | S60 Emulator |
| Category | Qt for Symbian | Subcategory | Application |
| Keywords (APIs, classes, methods, functions): Qvalidator,QLineEdit,QIntValidator |
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.
val->setbottom(1);
val->setTop(10);
#include <QtGui/QApplication>
#include "valid.h"
#include<QWidget>
#include<QLineEdit>
#include<QVBoxLayout>
#include <QIntValidator>
#include<QValidator>
#include<QLabel>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QLabel *lbl=new QLabel("QIntValidator");
QLineEdit *edit = new QLineEdit();
lbl->setBuddy(edit);
QValidator *val=new QIntValidator(1,10,edit);
edit->setValidator(val);
QVBoxLayout *lay=new QVBoxLayout();
lay->addWidget(lbl);
lay->addWidget(edit);
win->setLayout(lay);
win->show();
return a.exec();
}
Note: From the above code validator we can write the integer value between 1 to 10.You can't write value more than 10.
More AboutQIntValidator..
As you can see in the above image that we are unable to enter three digit value in QLineEdit,because the last and maximum possible value is "10" that is 2 digit.
From above image we can say that after pressing the "1" in keypad the Validator does not allowing us enter "11" in line edit as it maximum value is "10"
More AboutQIntValidator..
|
|
|