[PyQt] QDoubleSpinBox and decimal separator

Aaron Digulla digulla at hepe.com
Fri May 16 12:30:11 BST 2008

Quoting Henrik Pauli <henrik.pauli at gmail.com>:

>> In my locale, the decimal separator is ',' and not '.'. If I try to
>> write a decimal separator in a QDoubleSpinBox via the '.' button in the
>> numeric pad, the spinbox doesn't accept the value and I have to hit the
>> ',' button under the 'k' key. This happens also in the QDoubleSpinBox
>> example in the Qt (C++) Demo.
> Does your numeric-dot key really emit a period, or does it emit a comma?

Hint: You can use "xev" on Linux to see what really happens when a key  
is pressed.

On Windows, there should be a similar tool but I don't have a name handy.

As for a solution: Install a filter on the combo box and replace "."  
with the decimal separator you get back from QLocale. That would allow  
you to catch any other "dot" key anywhere else on the keyboard, too.


Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."

More information about the PyQt mailing list