QSpinBox repeated characters
-
I'm working with QSpinBoxes (or QDoubleSpinBoxes) and I'm finding that I often get keyboard inputs repeated. E.g. I type 5 and I get 55 in the box. At first I thought it was because I'm not calling processEvents in other parts of the program but that doesn't appear to help. Any ideas?
-
Hi,
What do you mean by "At first I thought it was because I’m not calling processEvents in other parts of the program" ?
What is your software doing ?
-
Originally, my main() had a fairly tight loop and I had this problem. I've since subclassed QApplication and I'm calling this loop off a one-shot timer. (I read about this method somewhere) Inside the slot called by the timer I call processEvents inside this tight loop. That doesn't seem to solve it though.
-
What does that loop do ?
-
Polls a joystick. Runs a PID controller. Talks to a motor controller. Repeat.
-
Sounds like it should rather run in its own thread
-
Well, everything else runs well except for edit boxes.
-
Do you mean that it also happen with other widgets containing QLineEdit ?
-
Yes. I put the joystick code in its own thread and that seems to have fixed it but I'm not sure. I thought I had fixed it once before too.
-
Depending on your loop size and speed, processEvents might not get called enough to be really helpful.
Using a secondary thread in this case is a better solution.