PDA

View Full Version : Negative numbers on QLineEdit



Cucus
21st April 2011, 18:09
Hi,

I'm trying to make an inputMask on my QLineEdit to ONLY accept negative and positive numbers with 2 decimals.

Is it possible to do it or I need a QDoubleValidator?

Thanks

mcosta
22nd April 2011, 13:51
You have to use QDoubleValidator or QRegExpValidator

For example this QRegExp works for you

QRegExp("[+-]?[1-9]\\d+\\.\\d{2}")