In Qt, I have a QScrollArea that has some content in it that can scroll vertically but should never, ever be allowed to scroll horizontally. Even if I disable the H scrollbars from showing, a mouse that has a scroll wheel (or touch pad) that supports horizontal motion will make it move a little bit side to side.
Now, this may partly be a layout issue… but nothing is actually off the screen.
It’s probably a cop-out, but is there a way to just “lock” the scroll area from behind able to move horizontally at all?
For your
QScrollAreayou need filterQEvent::WheelineventFiltermethod or overloadwheelEvent(QWheelEvent* event)method.Other way is create widget inherited from
QWidgetwith overloadedeventFilteronly and apply its filter to your scroll area: