[Qt-interest] line edits and commas

Duane duane.hebert at group-upc.com
Mon Apr 18 21:39:33 CEST 2011


On 4/18/2011 12:24 PM, Duane wrote:
> Using 4.7.1 LGPL version. MS Windows.
>
>
> QLineEdit with a double validator accepts '.' as valid as expected for
> the target default locale.  But it allows ',' to be entered. I am
> checking the state of the validator to determine when the string is
> acceptable rather than intermediate.
>
> But it isn't consistent as to whether the state is valid or
> intermediate.  For example, if I have it set with a min 0 and max 10 and
> the user enters 0,1 it returns acceptable but if the user enters 12,3 it
> returns intermediate.  0,1, is also acceptable.  0,1.2 is also
> acceptable.  It almost seems that it's trying to allow a thousands
> separator.  But according to the docs:
>
> In addition, QDoubleValidator is always guaranteed to accept a number
> formatted according to the "C" locale. QDoubleValidator will not accept
> numbers with thousand-separators.
>
>
> I'm able to handle this by checking for commas in the textChanged() slot
> and removing them but this behavior seems new and not correct.
> Actually, I don't think that it should return intermediate when
> encountering a comma in a locale that uses dots for decimal points.
>
>
> A second and maybe related problem is that a QSpinBox with a min of 0
> and some positive number for a max allows the user to enter commas.  It
> doesn't allow decimal separators so it must also be trying to use a
> thousands separator.
>
>
> Is this intended behavior in either case?

Just to follow up, when I build the project with 4.5.1 Windows 
commercial a line edit with a QDoubleValidator using the default locale 
(English Candian or US) doesn't allow commas entered at all.




More information about the Qt-interest-old mailing list