Results 1 to 6 of 6

Thread: what's wrong with my validator?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 42 Times in 37 Posts

    Default Re: what's wrong with my validator?

    Quote Originally Posted by jacek
    AFAIR QDoubleValidator permits the "scientific" notation, so you can write 1000000e-4 or -99999999e-5.
    Jacek is correct. If you don't need scientific notation, you can better achieve what you want with a regular expression validator:

    Qt Code:
    1. setValidator(new QRegExpValidator(QRegExp("[-+]?[0-9]{0,3}(\\.[0-9]{0,2})"), LineEdit));
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    29
    Thanked 3 Times in 2 Posts

    Default Re: what's wrong with my validator?

    Yes, of course, RegEx.
    just one thing though: at compile time I don't know what my min, max are.
    Still, no way around that without the work - I'll have convert my max to a string parse it and build my RegEx. Or validate by hand as suggested.

    Thanks guys,
    K

Similar Threads

  1. How to set Validator for individual cell in QTable
    By raghvendramisra in forum Qt Programming
    Replies: 3
    Last Post: 13th September 2008, 15:51
  2. Replies: 2
    Last Post: 2nd June 2008, 08:45
  3. IPAddress Validator RegExp
    By user_mail07 in forum Qt Programming
    Replies: 0
    Last Post: 3rd April 2008, 02:36
  4. Validator for QDoubleSpinBox
    By ehamberg in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2008, 11:37
  5. Help please - what am I doing wrong?
    By Jimmy2775 in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2006, 22:06

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.