Project

General

Profile

WIntValidator vs WDoubleValidator with WLineEdit

Added by Vincenzo Romano over 6 years ago

I can see that while the former doesn't allow for wrong characters (like letters and other symbols), the latter does.

Is this intentional or is there any other reason?

TALIA!


Replies (5)

RE: WIntValidator vs WDoubleValidator with WLineEdit - Added by Vincenzo Romano over 6 years ago

To be more precise, a WIntValidator doesn't allow the user to type in any illegal character.

So you cannot type letters and any symbol like % or &.

With the WDoubleValidator you can. Of course the validation fails in such a case.

RE: WIntValidator vs WDoubleValidator with WLineEdit - Added by Koen Deforche over 6 years ago

Hey,

This is because WDoubleValidator does not reimplement inputFilter(), but indeed it could and should.

See https://redmine.emweb.be/issues/6045

Regards,

koen

RE: WIntValidator vs WDoubleValidator with WLineEdit - Added by Vincenzo Romano over 6 years ago

There could be a pitfall in doing that.

Just like with WDateEdit. It's the localization.

For example, in Italy we use the comma (,) for the decimal point, while a lot of countries use the period (.) .

The inputFilter should follow the used locale, as the WDateEdit should, but doesn't.

For the former you can simply accept both and then let the use do the proper conversion, if needed.

But for the latter it's a different story.

See here !

    (1-5/5)