diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-11-17 15:20:28 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-11-17 15:23:40 (GMT) |
commit | 39463ccddd6f8c071da90e995ba5e76518738f94 (patch) | |
tree | 25e1dc1d894bdffbc2258fc171f5c4f31cce02f5 | |
parent | b914ba0d4dc1bc1e125fecde28c1be6a7ef90bb5 (diff) | |
download | Qt-39463ccddd6f8c071da90e995ba5e76518738f94.zip Qt-39463ccddd6f8c071da90e995ba5e76518738f94.tar.gz Qt-39463ccddd6f8c071da90e995ba5e76518738f94.tar.bz2 |
Mouse wheel wouldn't scroll the itemview when over header views
The mouse wheel event was not being relayed to the parent (supposedly QAbstractScrollArea) widget. Auto-test included.
Reviewed-by: Olivier
Task-number: QTBUG-5237
-rw-r--r-- | src/gui/itemviews/qheaderview.cpp | 7 | ||||
-rw-r--r-- | tests/auto/qtableview/tst_qtableview.cpp | 17 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 6f2cff9..5df8481 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -2396,7 +2396,12 @@ bool QHeaderView::viewportEvent(QEvent *e) d->state = QHeaderViewPrivate::NoState; d->pressed = d->section = d->target = -1; d->updateSectionIndicator(d->section, -1); - } + break; } + case QEvent::Wheel: { + QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea *>(parentWidget()); + if (asa) + return QApplication::sendEvent(asa->viewport(), e); + break; } default: break; } diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index f571e8a..33c7067 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -198,6 +198,7 @@ private slots: void task191545_dragSelectRows(); void taskQTBUG_5062_spansInconsistency(); void taskQTBUG_4516_clickOnRichTextLabel(); + void taskQTBUG_5237_wheelEventOnHeader(); void mouseWheel_data(); void mouseWheel(); @@ -3922,6 +3923,22 @@ void tst_QTableView::changeHeaderData() QVERIFY(view.verticalHeader()->width() > textWidth); } +void tst_QTableView::taskQTBUG_5237_wheelEventOnHeader() +{ + QTableView view; + QStandardItemModel model(500,5); + view.setModel(&model); + view.show(); + QTest::qWaitForWindowShown(&view); + + int sbValueBefore = view.verticalScrollBar()->value(); + QHeaderView *header = view.verticalHeader(); + QTest::mouseMove(header); + QWheelEvent wheelEvent(header->geometry().center(), -720, 0, 0); + QApplication::sendEvent(header->viewport(), &wheelEvent); + int sbValueAfter = view.verticalScrollBar()->value(); + QVERIFY(sbValueBefore != sbValueAfter); +} QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" |