[Qt-interest] A way to test the number of digits after a decimal point?

Israel Brewster israel at frontierflying.com
Tue Mar 31 18:06:35 CEST 2009


Are we assuming (perhaps through the use of a validator) that the  
entry is a valid decimal, and we just need to know the number of  
digits? If so, perhaps the following procedure would work.

1) Use the QString::indexOf function to find the position of the  
decimal.
2) Look at the difference between that and QString::Size to determine  
the number of digits after the decimal.

If you are looking for a way to limit the entry to being a certain  
number of decimals, then you want to look more  at Validators, but  
obviously you are already aware of them.
-----------------------------------------------
Israel Brewster
Computer Support Technician II
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------



On Mar 31, 2009, at 1:24 AM, Mihail Naydenov wrote:

>
> I need to test a string, representing a double, for the number of  
> digits after a decimal point.
>
> Looking into QDoubleValidator code, it uses locale().d()- 
> >validateChars(...), which also tests for the notation type, but  
> this is a private method, so it is a no-go.
> Were can I find a public alternative to these? Because both QString  
> and QLocal does not seam to have one.
>
> Thank You
> MihailNaydenov
>
>
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list