Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QSpinBox ValueChanged is fired many times

Let's suppose I have a QSpinBox with a value 123.45 in it. If I manually edit it and start erasing the five, valueChanged is fired for the value 123.4. Happens again if I go on erasing the four.

And it's also fired if I press enter after finishing editing.

I guess the problem is I should use void QAbstractSpinBox::editingFinished () instead of valueChanged, but it looks like valueChanged were the recommended approach as there are many more examples ans usage in my oppinion, so I want to be sure about this.

Any idea?

like image 415
Roman Rdgz Avatar asked Oct 23 '25 02:10

Roman Rdgz


2 Answers

Finally I found the keyboardTracking property in Qt Documentation. Easy to set, and works like a charm!

like image 197
Roman Rdgz Avatar answered Oct 24 '25 15:10

Roman Rdgz


It is fine in my opinion to use either signal, several of the Qt form elements have both an editingFinished and a ????Changed signal.

  • QLineEdit
  • QAbstractSpinBox sub-classes:
    • QDateTimeEdit
    • QDoubleSpinBox
    • QSpinBox

The multi-line QTextEdit only has a textChanged as pressing return creates a new line not move focus.

like image 33
Silas Parker Avatar answered Oct 24 '25 15:10

Silas Parker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!