summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-09-25 10:54:11 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-26 19:06:47 +0200
commitaec5b76b51fb1895f275ac4d413cc040cf88d519 (patch)
tree57b5f8d58778bb5d9c29b769e0b729888cee838d /tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
parentd535c910e443b974f0070cea2b3b000190450268 (diff)
[QTBUG-27308][QTBUG-21534] Don't mouse-wheel-scroll QScrollBar when disabled
This fixes a regression introduced in Qt 4 commit e855b199319c932f2e9500235775f961bc32e41a. The problem was that by handling the wheel event in event() instead of wheelEvent(), we lack the guard clause in QWidget that doesn't even call the handler if the widget is disabled, and the code didn't handle this itself. Fix by reimplementing wheelEvent() instead, which we can now do because we can break BC. This commit just moves the code. Another commit will clean up the implementation of wheelEvent(). Task-number: QTBUG-27308 Reported-by: chenjiexin Task-number: QTBUG-21534 Reported-by: Martin Koller Change-Id: Ibe6b89a81fe889f839c205b859a1492b39a4ddc3 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp')
-rw-r--r--tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
index 88c498cf07..4940372db9 100644
--- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
+++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
@@ -56,6 +56,9 @@ public slots:
private slots:
void scrollSingleStep();
void task_209492();
+#ifndef QT_NO_WHEELEVENT
+ void QTBUG_27308();
+#endif
private:
QScrollBar *testWidget;
@@ -143,5 +146,21 @@ void tst_QScrollBar::task_209492()
QCOMPARE(spy.count(), 1);
}
+#ifndef QT_NO_WHEELEVENT
+#define WHEEL_DELTA 120 // copied from tst_QAbstractSlider / tst_QComboBox
+void tst_QScrollBar::QTBUG_27308()
+{
+ // https://bugreports.qt-project.org/browse/QTBUG-27308
+ // Check that a disabled scrollbar doesn't react on wheel events anymore
+
+ testWidget->setValue(testWidget->minimum());
+ testWidget->setEnabled(false);
+ QWheelEvent event(testWidget->rect().center(),
+ -WHEEL_DELTA, Qt::NoButton, Qt::NoModifier, testWidget->orientation());
+ qApp->sendEvent(testWidget, &event);
+ QCOMPARE(testWidget->value(), testWidget->minimum());
+}
+#endif
+
QTEST_MAIN(tst_QScrollBar)
#include "tst_qscrollbar.moc"