PDA

View Full Version : QLineEdit validator() problem



ayanda83
29th August 2012, 18:05
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?

Ginsengelf
30th August 2012, 07:08
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

ChrisW67
30th August 2012, 23:40
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.