PDA

View Full Version : QValidatoe



sonuani
20th March 2008, 12:31
hi ,
i have a qlineedit which should accept only numbers and nothing else.I wrote the below code.This only allows me to enter a digit of length 10.But i should be able to enter a text of any length.Wts the prob with my code?

QValidator *validator = new QIntValidator(this);
m_ctrllineedit->setValidator(validator);

mattia
20th March 2008, 13:04
try to set a regular expression in the validator costructor


QRegExp regExp ( "initialize it with your expression" );
m_ctrllineedit->setValidator ( new QRegExpValidator ( regExp , this ) );

wysota
20th March 2008, 14:24
Did you set a range for the validator?

sonuani
21st March 2008, 04:00
Thank u very much.It works now.