PDA

View Full Version : QLineEdit - Float number not displayed correct



morty
6th November 2006, 11:15
Hi,

I am using QLineEdit to display a Float number.

When setting the the text using setText() then the number is not displayed correct.

For example the number '9.991' is displayed '9 .991', 1 or more spaces before the decimal point! This happens when I set the input mask to ###.###;

I tried other masks like 999.999; but same result. If I don't use a mask then it is displayed correct but then the user can enter alfanumeric characters!

I hope someone can help me on this.

Regards,
Morty

jpn
6th November 2006, 11:29
Have you tried without input mask and with a double validator instead?


// bottom (-999.0), top (999.0), decimals (2)
lineEdit->setValidator(new QDoubleValidator(-999.0, 999.0, 2, lineEdit));

morty
6th November 2006, 11:42
Hi,

Yes, I did try that.

I just thought it would be neater to prevent the user entering letters. And when it is possible to have a numeric mask that should prevent this, why not use it.

Have I misunderstood the use of the input mask?

Regards,
Morty

morty
9th November 2006, 00:47
I made a mistake when setting the QDoubleValidator so I could still enter letters.

Now that I have tried again and got it right I can see that it is only possible to enter numbers.

Problem solved.

Morty