PDA

View Full Version : QDecimalEdit - Help...!



Preeteesh
7th August 2007, 00:02
Can some one tell me how can i have a line edit where i show a . so that a user enter some value and it will move upto certain limit... What i am looking is something like DecimalEdit.... Which shows DOT in the lineedit and when user enter value the . is automatically adjusted...

I am using 000000009.00; in INputMask of my line edits but they seem to not have . Automatecally adjusted..

If possible please provie some sample code

marcel
7th August 2007, 00:31
I think the easiest way is to connect to the QLineEdit::textEdited(const QString&) and adjust the text yourself and set it back every time the user types something.
You can also change the cursor position, etc.

You must use that signal instead of textChanged, since it is not emitted when you change the text programmatically.

Regards

Preeteesh
7th August 2007, 11:36
Hey, can you provide me with some sample code..?

jpn
7th August 2007, 11:45
One possibility could be to use a custom validator. Do the required adjustments in reimplemented QValidator::fixup().

Preeteesh
7th August 2007, 11:58
can i have some small sample code?

jpn
7th August 2007, 12:25
Unfortunately I don't have anything at handy. Start with reading QValidator detailed description (http://doc.trolltech.com/4.3/qvalidator#details). Then,

subclass QValidator
reimplement QValidator::validate() and QValidator::fixup()
install the validator with QLineEdit::setValidator()