Results 1 to 20 of 30

Thread: QLineEdit set min max range?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit set min max range?

    Quote Originally Posted by whitefurrows
    Can you describe how your regexp work and i understand that. The problem is i have many other ranges to set e.g. 0-50, 15-32, 65-105 and i can't change your regexp.
    In such case, IMO, it would be better if you create your own validator class, because regexps aren't very readable.

    Anyway, suppose you want a regexp for 65-105 range. Valid numbers are:
    65, 66, 67, 68, 69, 70, ..., 79, 80, ..., 89, 90, ..., 99, 100, 101, 102, 103, 104, 105

    There are three possibilities:
    • 6 and one of {5, 6, 7, 8, 9} -> 6[5-9]
    • one of {7, 8, 9} and a digit -> [7-9]\\d
    • 10 and one of {0, 1, 2, 3, 4, 5} -> 10[0-5]

    and you just have to join them: 6[5-9]|[7-9]\\d|10[0-5]

    Quote Originally Posted by whitefurrows
    How can i set a QDoubleValidator its's easey, but my code don't work. I can set values out of range. Why?
    Because you can enter 1500.00e-2, which is a valid number.
    Last edited by jacek; 21st May 2006 at 16:28. Reason: fixed a typo

  2. The following user says thank you to jacek for this useful post:

    whitefurrows (10th June 2006)

Similar Threads

  1. Replies: 10
    Last Post: 12th February 2009, 07:23
  2. QLineEdit
    By rick_st3 in forum Newbie
    Replies: 1
    Last Post: 14th June 2008, 09:05
  3. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  4. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 01:25
  5. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12:48

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
  •  
Qt is a trademark of The Qt Company.