PDA

View Full Version : Unit always visible in QLineEdit



zack
12th January 2010, 18:44
I want to have a QLineEdit, where the user can input numbers.

After the number there should be always a unit shown (e.g. 'mm').
The user should not be able to delete the mm, select or do what ever with it.
The LayoutDirection is from left to right.

I thougt a simple solution can be to add another LineEdit to the first one.
And modify the style of the "unit - LineEdit" so that is looks like the two are one together.

Or is there a better solution?Maybe with inputmask something?

mattc
12th January 2010, 18:50
You can do that with a QSpinBox and QSpinBox::setSuffix()

zack
13th January 2010, 09:58
That doesn't work very well, I have the layout direction right to left, but the suffix is still before the number, also when I use the prefix.
I think thats a bug.

And the other think is I don't want to limit the user in his input value, e.g. how many digits before and after the point.