I have a QSpinBox in a QMainWindow holding a value. Natively the spinbox, well ... spins on QWheelEvent if focused. I would like to expand the scrolling of the value in the spinbox to be applied invariantly of focus within the window.
The spinbox manages a value that dictates behavior to the whole context of the window live.
I am trying to divert the scroll event to the spinbox to be handled by the latter to implement this instead of handling a custom value somewhere and to synchronize it with the spinbox manually.
But I am failing. I have an EventFilter in the window that can intercept the event in the window invariantly of focus, but the wheelEvent method in the spinbox is protected so I cannot call it from there.
I do not want to just make a custom spinbox for this if I can help it.
Any ideas?
CodePudding user response:
In the event filter, do not call the protected spinBox->wheelEvent(wheelEvent). You can instead pass the event to the spin box using static function QCoreApplication::sendEvent(spinBox, wheelEvent).
Of course, seeing your code would help to show more concrete solution. Especially you should make sure that your event filter does not intercept this re-sent event again, creating an infinite loop...
