Results 1 to 4 of 4

Thread: QValidatoe

  1. #1
    Join Date
    Feb 2008
    Posts
    47
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post QValidatoe

    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);

  2. #2
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QValidatoe

    try to set a regular expression in the validator costructor
    Qt Code:
    1. QRegExp regExp ( "initialize it with your expression" );
    2. m_ctrllineedit->setValidator ( new QRegExpValidator ( regExp , this ) );
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QValidatoe

    Did you set a range for the validator?

  4. #4
    Join Date
    Feb 2008
    Posts
    47
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post Re: QValidatoe

    Thank u very much.It works now.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.