Results 1 to 5 of 5

Thread: validator on line edit

  1. #1
    Join Date
    May 2010
    Posts
    42

    Question validator on line edit

    Hi guys!
    I want to set validator on line edit.but it doesn't work.
    my code is:
    QRegExp rx("[0-9]{1,2}|24");
    SlineEdit->setValidator(new QRegExpValidator(rx,SlineEdit));
    which I want to set 0-24 available,but it doesn't work!

  2. #2
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: validator on line edit

    In your case, you can use QIntValidator.

  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: validator on line edit

    And code snippet
    Qt Code:
    1. QValidator *val = new QIntValidator(0, 24, this);
    2. ui->lineEdit->setValidator( val );
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2010
    Posts
    42

    Default Re: validator on line edit

    Quote Originally Posted by Talei View Post
    And code snippet
    Qt Code:
    1. QValidator *val = new QIntValidator(0, 24, this);
    2. ui->lineEdit->setValidator( val );
    To copy to clipboard, switch view to plain text mode 
    this method i know,i just want to use QRegExp rx("[0-9]{1,2}|24") syntax.thank you all the same!

  5. #5
    Join Date
    May 2010
    Posts
    42

    Default Re: validator on line edit

    Quote Originally Posted by saa7_go View Post
    In your case, you can use QIntValidator.
    this method i know,i just want to use QRegExp rx("[0-9]{1,2}|24") syntax.thank you all the same!

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 20:06
  2. Replies: 3
    Last Post: 26th August 2010, 09:57
  3. line edit focus
    By addu in forum Qt Programming
    Replies: 3
    Last Post: 16th July 2009, 16:39
  4. mask line edit
    By steg90 in forum Qt Programming
    Replies: 4
    Last Post: 3rd July 2007, 11:27
  5. Replies: 8
    Last Post: 15th May 2007, 10:21

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.