I've got a spinbox widget (QDoubleSpinBox) which is used to send a command over a serial port to a hardware device. The desired behavior was the valueChanged() signal was connected directly to the sendCommand() slot, but we're running into a problem with the hardware device not being able to keep up when the user uses the keyboard to change the value.
What we're noticing is that if the user holds down the mouse button on one of the GUI controls, the spinbox increments at a certain rate - a rate that the serial port and device can keep up with. But if the user uses the keyboard up/down keys to change the control and holds down the key, the rate the spinbox increments is MUCH faster than the mouse method. Unfortunately due to a bug in the hardware device it gets confused with all these commands coming that quickly, but we're not able to change the device firmware very easily.
So I'm looking for a way to slow down the valueChanged() signals when using a keyboard. The only thing I can find is that spinboxes have an "accelerated" property, but I've already verified that is set to false.
Is there anything else I can do? The only solution I can think of is instead of connecting the valueChanged() signal directly to my sendCommand() slot, I could put an intermediate slot with a timer in between, so the valueChanged() signal causes this intermediate slot to store the value and start a timer, if the timer expires, then the sendCommand() slot would get called, but otherwise the timer keeps getting reset and no command gets sent.
Am I missing another solution?
Bookmarks