diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-11 15:28:24 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-11 15:35:59 (GMT) |
commit | 46a3e518b3070cf7cb4cbbb2cb58254454cf169d (patch) | |
tree | 5f3713cc524d59f09db230b4bcacb26008980070 /src/gui/widgets/qabstractscrollarea.cpp | |
parent | 2b6fd0a7bdac686a41d7fbbe47ad3ded9e1d77b5 (diff) | |
download | Qt-46a3e518b3070cf7cb4cbbb2cb58254454cf169d.zip Qt-46a3e518b3070cf7cb4cbbb2cb58254454cf169d.tar.gz Qt-46a3e518b3070cf7cb4cbbb2cb58254454cf169d.tar.bz2 |
QAbstractScrollArea: Wheel over a scrollarea that has only one horizontal scrollbar
If the vertical scrollbar is hidden, scroll using the other scrollbar.
Reviewed-by: Thierry
Task-number: QTBUG-1760
Diffstat (limited to 'src/gui/widgets/qabstractscrollarea.cpp')
-rw-r--r-- | src/gui/widgets/qabstractscrollarea.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index 48099ef..c186645 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -1130,10 +1130,13 @@ void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e) void QAbstractScrollArea::wheelEvent(QWheelEvent *e) { Q_D(QAbstractScrollArea); - if (static_cast<QWheelEvent*>(e)->orientation() == Qt::Horizontal) - QApplication::sendEvent(d->hbar, e); - else - QApplication::sendEvent(d->vbar, e); + QScrollBar *const bars[2] = { d->hbar, d->vbar }; + int idx = (e->orientation() == Qt::Vertical) ? 1 : 0; + int other = (idx + 1) % 2; + if (!bars[idx]->isVisible() && bars[other]->isVisible()) + idx = other; // If the scrollbar of the event orientation is hidden, fallback to the other. + + QApplication::sendEvent(bars[idx], e); } #endif |