PDA

View Full Version : Money Format



newermind
19th May 2009, 13:11
I have a QLineEdit, and when user enter some number into it, i want to replace that string with its currency represantation.

I tried to change the input on textChanged(const QString&) signal on that QlineEdit object, but i had involved lots of problems.

IMHO, There must be easy way to tell QLineEdit, use that locale to change numbers into currency.

wysota
19th May 2009, 15:00
What exactly is the problem?

fifth
19th May 2009, 15:08
I have a QLineEdit, and when user enter some number into it, i want to replace that string with its currency represantation.

I tried to change the input on textChanged(const QString&) signal on that QlineEdit object, but i had involved lots of problems.

IMHO, There must be easy way to tell QLineEdit, use that locale to change numbers into currency.

Rather than textChanged() were you will be changing the text as the user types, try editingFinished() where you can write a 'fixup' routine to format the text. The routine will trigger when the user tabs out or clicks out of the QLineEdit.

faldzip
19th May 2009, 15:34
Did you tried implementing your own validator? Subclass QValidator for checking if the input is right (for example no letters between digits), and fixing input data with QValidator::fixup().
Don't know if it's the best and fastest way but I would give it a try.