QDoubleSpinBox thousand separator while user is typing

Viewed 471

I want to make a QDoubleSpinBox that would format the value into currency so it would be readable by users.

Example.

enter image description here

So far I've accomplished these things:

  • set showGroupSeparator to true - but it will only work when focus is released.
  • used the valueChanged signal to update the group separators directly by calling ui->doubleSpinBox->setValue(amount);

    void DialogCashPayment::on_sbAmount_valueChanged(double arg1)
    {
        ui->sbAmount->setValue(arg1);
    }
    

The Problem is

The cursor position will not be in the correct position when the amount is > than 10k, sometimes the amount will completely disappear. in short its really buggy.

Is there any approach on this? Maybe I've overlooked something simple. Please raise a comment if something is not clear. Thanks!

0 Answers
Related