PDA

View Full Version : QDoubleValidator and setDecimals



zorro68
11th February 2007, 17:39
Why this code not work:



QDoubleValidator *qv= new QDoubleValidator(parent);
qv->setDecimals(2);
editor->setValidator(qv);


The number takes all decimals, not only 2

jacek
11th February 2007, 18:04
The number takes all decimals, not only 2
Because you can enter also: 1.234567e4.

wysota
11th February 2007, 19:18
Use a reg exp validator with a regexp set to "\d*\.\d{1,2}" instead if you want to disallow the scientific notation. Remember about escaping backslashes.