Qt - Is there a signal for each lost focus on QSpinBox just when the value changes?

StackOverflow https://stackoverflow.com/questions/19539957

  •  01-07-2022
  •  | 
  •  

I need to capture whole changed value just when the widget loses focus.

I know I have valueChanged() and editingFinished() signals. The problem with valueChanged() signal is that it will be fired for each pressed key and the problem with editingFinished() is that it is fired even when his value don't change.

The question is: Is possible to have a signal fired for each lost focus just when the value changes?

If don't, comes a new question: Is there a way to get the widget's old value inside a slot connected at editingFinished() for comparison against current value and decision if the value change occurred?

有帮助吗?

解决方案

You can try extend the QSpinBox and then reimplement focusOutEvent()
http://qt-project.org/doc/qt-5.0/qtwidgets/qwidget.html#focusOutEvent

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top