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 QScrollArea
you need filter QEvent::Wheel
in eventFilter
method or overload wheelEvent(QWheelEvent* event)
method.
Other way is create widget inherited from QWidget
with overloaded eventFilter
only and apply its filter to your scroll area:
scrollArea->viewport()->installEventFilter(someFilterWidget);
scrollArea->verticalScrollBar()->setEnabled(false);
scrollArea->horizontalScrollBar()->setEnabled(false);
Did you try to set the scroll bar policy ?
myScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
http://qt-project.org/doc/qt-4.8/qabstractscrollarea.html#horizontalScrollBarPolicy-prop