Results 1 to 3 of 3

Thread: QLineEdit validator() problem

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QLineEdit validator() problem

    I'm suppose to use the QLineEdit component to read "double" values from the keyboard. The program is suppose to pop-up an error window in case the user enters a non-digit value. And also, which function holds the value of the QLineEdit?

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    518
    Thanks
    13
    Thanked 77 Times in 75 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit validator() problem

    Hi, you should use a QDoubleSpinBox instead of the QLineEdit, but in case you can't do that: the current text of the QLineEdit can be accessed by QLineEdit::text(), and you may want to look at QDoubleValidator.

    Ginsengelf

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLineEdit validator() problem

    Read the answer in the last thread you started on this exact topic.

    If you must use a QLineEdit then QDoubleValidator will prevent (no error message) any character that cannot possibly be part of a number, and can tell you if what remains meets the other validation criteria. See this thread also.

Similar Threads

  1. QLineEdit inputMask and validator
    By vhptt in forum Newbie
    Replies: 3
    Last Post: 1st September 2012, 02:36
  2. QLineEdit validator
    By pobere in forum Newbie
    Replies: 2
    Last Post: 5th November 2011, 10:16
  3. QSpinBox validator problem
    By batileon in forum Newbie
    Replies: 3
    Last Post: 29th September 2011, 15:54
  4. Use QLineEdit with mask AND validator for money OUTPUT
    By luboni in forum Qt Programming
    Replies: 4
    Last Post: 16th August 2011, 17:29
  5. Validator
    By tinysoft in forum Newbie
    Replies: 5
    Last Post: 13th April 2011, 16:00

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.