diff options
author | Liang Qi <liang.qi@qt.io> | 2019-08-27 09:45:52 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-08-27 09:45:52 +0200 |
commit | 0f1f7fb97fd0dd572ad61a0ebaef68c2bba72e57 (patch) | |
tree | e1f3f1b58aa69904e6bc629e88ed68fca858f83a /examples | |
parent | e8c70fb07f01b492b721451c00496f860eb40be0 (diff) | |
parent | 5bb178c479a247720fbc3fbb7f06a32b725193ac (diff) |
Merge remote-tracking branch 'origin/dev' into 5.14
Conflicts:
src/widgets/kernel/qwidget.cpp
src/widgets/kernel/qwidget_p.h
src/widgets/kernel/qwidgetrepaintmanager.cpp
src/widgets/kernel/qwidgetwindow.cpp
tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
Change-Id: Ifae457d0427be8e2465e474b055722e11b3b1e5c
Diffstat (limited to 'examples')
6 files changed, 12 insertions, 11 deletions
diff --git a/examples/corelib/threads/doc/src/mandelbrot.qdoc b/examples/corelib/threads/doc/src/mandelbrot.qdoc index 274874632e..9e3fdc1dfe 100644 --- a/examples/corelib/threads/doc/src/mandelbrot.qdoc +++ b/examples/corelib/threads/doc/src/mandelbrot.qdoc @@ -304,8 +304,8 @@ \snippet threads/mandelbrot/mandelbrotwidget.cpp 12 The wheel event handler is reimplemented to make the mouse wheel - control the zoom level. QWheelEvent::delta() returns the angle of - the wheel mouse movement, in eights of a degree. For most mice, + control the zoom level. QWheelEvent::angleDelta() returns the angle + of the wheel mouse movement, in eighths of a degree. For most mice, one wheel step corresponds to 15 degrees. We find out how many mouse steps we have and determine the resulting zoom factor. For example, if we have two wheel steps in the positive direction diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp index 71d0abb09f..822791533b 100644 --- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp +++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp @@ -176,7 +176,7 @@ void MandelbrotWidget::keyPressEvent(QKeyEvent *event) //! [12] void MandelbrotWidget::wheelEvent(QWheelEvent *event) { - int numDegrees = event->delta() / 8; + int numDegrees = event->angleDelta().y() / 8; double numSteps = numDegrees / 15.0f; zoom(pow(ZoomInFactor, numSteps)); } 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"; |