summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qscrollbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qscrollbar.cpp')
-rw-r--r--src/widgets/widgets/qscrollbar.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp
index 34ea017279..2ce1d50c86 100644
--- a/src/widgets/widgets/qscrollbar.cpp
+++ b/src/widgets/widgets/qscrollbar.cpp
@@ -497,14 +497,20 @@ bool QScrollBar::event(QEvent *event)
void QScrollBar::wheelEvent(QWheelEvent *event)
{
event->ignore();
+ bool horizontal = qAbs(event->angleDelta().x()) > qAbs(event->angleDelta().y());
+ // The vertical wheel can be used to scroll a horizontal scrollbar, but only if
+ // there is no simultaneous horizontal wheel movement. This is to avoid chaotic
+ // scrolling on touchpads.
+ if (!horizontal && event->angleDelta().x() != 0 && orientation() == Qt::Horizontal)
+ return;
// scrollbar is a special case - in vertical mode it reaches minimum
// value in the upper position, however QSlider's minimum value is on
// the bottom. So we need to invert the value, but since the scrollbar is
// inverted by default, we need to invert the delta value only for the
// horizontal orientation.
- int delta = (orientation() == Qt::Horizontal ? -event->angleDelta().x() : event->angleDelta().y());
+ int delta = horizontal ? -event->angleDelta().x() : event->angleDelta().y();
Q_D(QScrollBar);
- if (d->scrollByDelta(orientation(), event->modifiers(), delta))
+ if (d->scrollByDelta(horizontal ? Qt::Horizontal : Qt::Vertical, event->modifiers(), delta))
event->accept();
if (event->phase() == Qt::ScrollBegin)