PDA

View Full Version : How to set precision for line edit



shivendra46d
24th September 2013, 14:00
I want that my line edit should take value up to two places after decimal in a given range 0.1 to 179.90 i tried this but its setting the precision up to one place after decimal but not the range

ui->RayInitialAngle_lineEdit->setValidator(new QDoubleValidator(0.10,179.90,1,this));

aamer4yu
24th September 2013, 15:43
You are passing the decimal places as 1 !!

shivendra46d
25th September 2013, 06:47
thanks that sets the precision. Now i want that it should take values in given range only how to do that?

anda_skoa
25th September 2013, 10:28
Just to make sure: you had a look at QDoubleSpinBox?

Cheers,
_

ChrisW67
26th September 2013, 01:37
The line edit with validator acts as documented, only emitting editingFinished()/retunrPressed() on focus loss/Return when the value entered is Acceptable. The value entered may be Intermediate and focus will still be lost. For example, given the range 0.0 to 100.0 the validator will allow the user to type 345 and tab out of the field. That value is Intermediate because the user could finish typing "345e-1" which is an Acceptable value in the range.