Qt DoubleSpin Box value changed slot has called twice
-
@Sowmiya-R
Must be something in your Qt/compiler I guess ??
Can you try this test
https://www.dropbox.com/s/9eftxqghndn2bhw/myspinbox.zip?dl=0 -
@Sowmiya-R ,
Hi,
You can use Qt::UniqueConnection in Connect statement. -
@Sowmiya-R
Ahh, now i see.
Yes the debugger seems to interfere with event loop so it does indeed call it twice on one click
if u place break point there. Else Not.void MainWindow::on_doubleSpinBox_valueChanged(const QString &arg1) { static int hmm=0; qDebug() << arg1; hmm++; qDebug() << hmm; }
"1,00"
1
"2,00"
2I would guess that pausing it triggers the repeat feature and since it dont get an mouse release event its why.
-
I have developed a application using Qt, there regardless of debug mode or release mode value changed slot has called twice only on spinbox box up/down controls.
I try to reproduce the same in sample application, but its happening only in debug mode.There is something missing in my application. I will check it out.
Thank you guys for you suggestions. -
But it ONLY happens for me if i set break point.
Never, ever else.Do it happen for you if yo have NO break points ?
-
@Sowmiya-R
Ok, that does not happen for me.
Without break point it works correctly here.I have no idea what could be wrong with your Qt.
Since you are using a clean project to test, i assume is something with your pc or Qt.
-
@Wael11
For anyone reading this: This is known behaviour, which I stumbled across a long time ago and it was infuriating.With a
QSpinbox
Qt 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()
toQSpinbox
click/key to passQt::QueuedConnection
as 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.