PDA

View Full Version : QRegExp?



Marco812
3rd August 2006, 18:41
Hi,

how can i set a range (0.24 – 2.06) to a QLineEdit with a QRegExp?

I try this


QRegExp regExpRange("(?:[0-2]24)(?:[.,]\\d\\d?)?|2(?:[.,]06?)?"); //Range 0.25 – 2.05
myQLineEdit->setValidator(new QRegExpValidator(regExpRange, this));

Thanks in advance

Marco812

jacek
3rd August 2006, 20:03
Try:
"0[.,]2[4-9]|0[.,][3-9]\\d|1[.,]\\d\\d|2.0[0-6]"but maybe QDoubleSpinBox will be more usefull? There is also QDoubleValidator.

Marco812
3rd August 2006, 21:10
Hi,

thank you for the tip, but i think in this case is better to use QRegExp as a QDoubleValidator. Your QRegExp is OK, thank you.

Greetings

Marco812

Marco812
4th August 2006, 09:31
Hi,

sorry i have found an error. I can put values like "2100" or "23" or "24".... I think that's OK:


"0[.,]2[4-9]|0[.,][3-9]\\d|1[.,]\\d\\d|2[.,]0[0-6]"

Greetings,

Marco812