[Qt-interest] Why this double is not valid by QDoubleValidator

Murphy, Sean M. sean.murphy at gd-ais.com
Thu Aug 27 15:57:51 CEST 2009


>> Dear Friends Why QDoubleValidator is not accepting the value below as
a
>> double with default settings.
>> 
>> "-0.0000888889E"
> 
> is E a valid double?
> Did you miss out the exponent?

The string you have above at this point is not a valid double, you'd
need some more digits after the 'E', or have the string end before the
'E'.  

In your sample code, you only show that you are checking that validate()
returns QValidator::Acceptable or if not, you drop into the "else"
portion of your if-else.  But validate() has 3 possible return states,
Acceptable, Intermediate, or Invalid.  I'd imagine that if you checked
if validate() returns QValidator::Intermediate that is probably what it
is returning at this point.  Some something like

if (validate() == QValidator::Acceptable)
{
  // do something
} else if (validate() == QValidator::Intermediate) {
  // do something else, probably just wait for more user input
} else {
  // clearly invalid, do whatever you do for errors
}

Sean




More information about the Qt-interest-old mailing list