Qt DoubleSpin Box value changed slot has called twice
-
The double call to slot happened in my case only with a breakpoint in the slot function, otherwise it is called once only. The second call was triggered by a timer event
@Wael11
For anyone reading this: This is known behaviour, which I stumbled across a long time ago and it was infuriating.With a
QSpinboxQt Internal code uses a timer on clicks/presses. If you step through in debugger you exceed the timeout and get bad/double behaviour.Simplest: change all
connect()toQSpinboxclick/key to passQt::QueuedConnectionas last parameter for connection type, not defaultQt::DirectConnection. Now you can use debugger breakpoints and all will be well. I wrote a method to connect all my spinboxes like this.