Kanishka Weerasekara
Kanishka Weerasekara

Reputation: 57

Naturally type decimal values with QDoubleSpinBox

QDoubleSpinBox functionality is required to provide the user with the option to simply click the arrow keys and easily increase the value by certain points. But it is absolutely necessary that the user is able to enter the decimal value manually as well. Eg. If he needs to type 12.25 by typing, he should be able to. But if he needs to increase it by 0.01 he still should be able to use the arrows in the spinbox and do it as well.

Under normal configurations he can not enter 12.25 at one go. if he types 12 and then the decimal point, it does not move to the decimal section of the spin box, or even after that you have to select 0.1 and type the 0.1 section and then move to 0.01 using arrow keys and type the 0.01 part of the dobule value.

Is there any property that will help me get the expected behaviour of typing 12.15 in one go, without selecting each and every digit.

Upvotes: 1

Views: 2312

Answers (1)

Marco A.
Marco A.

Reputation: 43662

Depending on the locale (http://qt-project.org/doc/qt-5/qwidget.html#setLocale) you might have to take a look at the decimal separator your control is expecting (e.g. ',' or '.').

You can either set the locale as you prefer or override this behavior by subclassing the control in the keyPressEvent

Upvotes: 0

Related Questions