diff options
Diffstat (limited to 'examples/widgets')
4 files changed, 9 insertions, 8 deletions
diff --git a/examples/widgets/graphicsview/chip/view.cpp b/examples/widgets/graphicsview/chip/view.cpp index 9676c13ff7..7d5fd699a4 100644 --- a/examples/widgets/graphicsview/chip/view.cpp +++ b/examples/widgets/graphicsview/chip/view.cpp @@ -68,7 +68,7 @@ void GraphicsView::wheelEvent(QWheelEvent *e) { if (e->modifiers() & Qt::ControlModifier) { - if (e->delta() > 0) + if (e->angleDelta().y() > 0) view->zoomIn(6); else view->zoomOut(6); diff --git a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp index 6b817b2a21..9341d77f8d 100644 --- a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp +++ b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp @@ -190,7 +190,7 @@ void GraphWidget::timerEvent(QTimerEvent *event) //! [5] void GraphWidget::wheelEvent(QWheelEvent *event) { - scaleView(pow((double)2, -event->delta() / 240.0)); + scaleView(pow((double)2, -event->angleDelta().y() / 240.0)); } //! [5] #endif diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp index 482e0f3268..50acf0f814 100644 --- a/examples/widgets/painting/affine/xform.cpp +++ b/examples/widgets/painting/affine/xform.cpp @@ -260,7 +260,7 @@ void XFormView::timerEvent(QTimerEvent *e) #if QT_CONFIG(wheelevent) void XFormView::wheelEvent(QWheelEvent *e) { - m_scale += e->delta() / qreal(600); + m_scale += e->angleDelta().y() / qreal(600); m_scale = qMax(qreal(0.1), qMin(qreal(4), m_scale)); emit scaleChanged(int(m_scale*1000)); } diff --git a/examples/widgets/widgets/mousebuttons/buttontester.cpp b/examples/widgets/widgets/mousebuttons/buttontester.cpp index 6653221698..88dbbeda45 100644 --- a/examples/widgets/widgets/mousebuttons/buttontester.cpp +++ b/examples/widgets/widgets/mousebuttons/buttontester.cpp @@ -93,15 +93,16 @@ void ButtonTester::mouseDoubleClickEvent(QMouseEvent *e) void ButtonTester::wheelEvent (QWheelEvent *e) { QString result; - if (e->delta() > 0) { - - if (e->orientation() == Qt::Vertical) { + const bool vertical = qAbs(e->angleDelta().y()) >= qAbs(e->angleDelta().x()); + const int delta = vertical ? e->angleDelta().y() : e->angleDelta().x(); + if (delta > 0) { + if (vertical) { result = "Mouse Wheel Event: UP"; } else { result = "Mouse Wheel Event: LEFT"; } - } else if (e->delta() < 0) { - if (e->orientation() == Qt::Vertical) { + } else if (delta < 0) { + if (vertical) { result = "Mouse Wheel Event: DOWN"; } else { result = "Mouse Wheel Event: RIGHT"; |