PDA

View Full Version : QDoubleValidator



gt.beta2
5th February 2009, 16:09
Hello!
Showld't this lineEdit be accepting values from [0, 20] with one decimal?!

lineEdit->setValidator(new QDoubleValidator(0.0, 20.0, 1, this));

Thanks

wysota
5th February 2009, 16:11
Yes, it should.

gt.beta2
5th February 2009, 16:23
Then i better take a good look because this lineEdit is accepting me values out of that range.
"I'll be back" :cool:

wysota
5th February 2009, 16:50
No, it is not. These are intermediate values because you can always write 200000E-5 to get 20. If you want the usual notation only, it is better to use a regexp validator:

new QRegExpValidator(QRegExp("\\d?\\d?(\\.\\d)?"), this);

or QDoubleSpinBox.

gt.beta2
5th February 2009, 17:46
Yeah ... i was reading about this "limitation" a while ago.
Back to where i came from ... the RegExp :)

Thanks

wysota
5th February 2009, 19:44
It's not a limitation, it's an extension (or relaxation) :)