Results 1 to 6 of 6

Thread: QDoubleValidator

  1. #1
    Join Date
    Jan 2009
    Posts
    78
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default QDoubleValidator

    Hello!
    Showld't this lineEdit be accepting values from [0, 20] with one decimal?!
    Qt Code:
    1. lineEdit->setValidator(new QDoubleValidator(0.0, 20.0, 1, this));
    To copy to clipboard, switch view to plain text mode 

    Thanks

  2. #2
    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: QDoubleValidator

    Yes, it should.

  3. #3
    Join Date
    Jan 2009
    Posts
    78
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default Re: QDoubleValidator

    Then i better take a good look because this lineEdit is accepting me values out of that range.
    "I'll be back"

  4. #4
    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: QDoubleValidator

    No, it is not. These are intermediate values because you can always write 200000E-5 to get 20. If you want the usual notation only, it is better to use a regexp validator:
    Qt Code:
    1. new QRegExpValidator(QRegExp("\\d?\\d?(\\.\\d)?"), this);
    To copy to clipboard, switch view to plain text mode 

    or QDoubleSpinBox.

  5. The following user says thank you to wysota for this useful post:

    gt.beta2 (5th February 2009)

  6. #5
    Join Date
    Jan 2009
    Posts
    78
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default Re: QDoubleValidator

    Yeah ... i was reading about this "limitation" a while ago.
    Back to where i came from ... the RegExp

    Thanks

  7. #6
    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: QDoubleValidator

    It's not a limitation, it's an extension (or relaxation)

Similar Threads

  1. Replies: 15
    Last Post: 1st October 2008, 23:43
  2. QDoubleSpinBox and QDoubleValidator
    By George Neil in forum Qt Programming
    Replies: 1
    Last Post: 26th June 2008, 00:36
  3. QDoubleValidator and setDecimals
    By zorro68 in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2007, 18:18
  4. QDoubleValidator
    By cristiano in forum Qt Programming
    Replies: 7
    Last Post: 19th January 2007, 21:10

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.