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
  •  | 
  •  

Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top