[Qt-interest] QIntValidator not working as expected
Andre Somers
andre at familiesomers.nl
Sat Sep 25 11:40:57 CEST 2010
Op 25-9-2010 6:47, Aaron Lewis schreef:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 09/24/2010 07:50 PM, Pradeep K Vijayan wrote:
> > Hi,
>
> >
>
> > 0 is allowed because appending few numbers after 0 makes
> the entry
>
> > valid. For ex, 0001 is a valid number in your case. Empty
> text and
>
> > 0 in your lineedit puts the validator in 'Intermediate'
> state.
>
> >
>
> > http://doc.trolltech.com/4.7/qintvalidator.html#validate
>
> Thanks , so was there any hints for my need ?
Yes: you misunderstand your need. Inputting one or more zeroes is valid
for your use case of wanting an integer between 1 and 254. For integers,
001 == 1 -> valid. So 00 is 'intermediate', because it could still
*become* valid input. Also, making input like that impossible hinders
your users. What if somebody accidentally typed in 102, and wanted to
type 202. He would delete the 1 (thus temporarily get 02) and type a 2.
You want to prevent that, as the input may in your vision not start with
a 0. Not very user friendly.
André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100925/b8a07b37/attachment.html
More information about the Qt-interest-old
mailing list