You Are Here:

Community: Wiki

This page was last modified on 31 October 2009, at 14:15.

How to use QIntValidator

From Forum Nokia Wiki



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

Introduction

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().

Preconditions

Various Functions

Note: val is object of QValidator.

  • This property holds the validator's lowest acceptable value.
val->setbottom(1);
  • This property holds the validator's highest acceptable value.
val->setTop(10);


Source File

main.cpp

#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.

Screenshot

More AboutQIntValidator..

Image:Intvalid.JPG 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.


Image:Intvalid1.JPG 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..

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fGuaranaUIE2dE44ocumentationX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ