diff options
25 files changed, 172 insertions, 253 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index e1d685b1b0..2ec90433d6 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -754,31 +754,15 @@ QHoverEvent::~QHoverEvent() \fn Qt::Orientation QWheelEvent::orientation() const \obsolete - Returns the wheel's orientation. - Use angleDelta() instead. */ +#if QT_CONFIG(wheelevent) +#if QT_DEPRECATED_SINCE(5, 14) /*! \obsolete - Constructs a wheel event object. - - Use the constructor taking \e angleDelta and \e pixelDelta QPoints instead. - - The position, \a pos, is the location of the mouse cursor within - the widget. The globalPos() is initialized to QCursor::pos() - which is usually, but not always, correct. - Use the other constructor if you need to specify the global - position explicitly. - - The \a buttons describe the state of the mouse buttons at the time - of the event, \a delta contains the rotation distance, - \a modifiers holds the keyboard modifier flags at the time of the - event, and \a orient holds the wheel's orientation. - - \sa pos(), pixelDelta(), angleDelta() + This constructor has been deprecated. */ -#if QT_CONFIG(wheelevent) QWheelEvent::QWheelEvent(const QPointF &pos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient) @@ -793,26 +777,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, int delta, } /*! - \internal -*/ -QWheelEvent::~QWheelEvent() -{ -} - -/*! \obsolete - Constructs a wheel event object. - - Use the constructor taking \e angleDelta and \e pixelDelta QPoints instead. - - The \a pos provides the location of the mouse cursor - within the widget. The position in global coordinates is specified - by \a globalPos. \a delta contains the rotation distance, \a modifiers - holds the keyboard modifier flags at the time of the event, and - \a orient holds the wheel's orientation. - - - \sa pos(), pixelDelta(), angleDelta() + This constructor has been deprecated. */ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, @@ -827,27 +793,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta } /*! - Constructs a wheel event object. - - The \a pos provides the location of the mouse cursor - within the window. The position in global coordinates is specified - by \a globalPos. - - \a pixelDelta contains the scrolling distance in pixels on screen, while - \a angleDelta contains the wheel rotation distance. \a pixelDelta is - optional and can be null. - - The mouse and keyboard states at the time of the event are specified by - \a buttons and \a modifiers. - - For backwards compatibility, the event can also hold monodirectional wheel - event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the - direction. - - The phase() is initialized to Qt::ScrollUpdate. Use the other constructor - to specify the phase explicitly. - - \sa posF(), globalPosF(), angleDelta(), pixelDelta() + \obsolete + This constructor has been deprecated. */ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, @@ -858,26 +805,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, {} /*! - Constructs a wheel event object. - - The \a pos provides the location of the mouse cursor - within the window. The position in global coordinates is specified - by \a globalPos. - - \a pixelDelta contains the scrolling distance in pixels on screen, while - \a angleDelta contains the wheel rotation distance. \a pixelDelta is - optional and can be null. - - The mouse and keyboard states at the time of the event are specified by - \a buttons and \a modifiers. - - For backwards compatibility, the event can also hold monodirectional wheel - event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the - direction. - - The scrolling phase of the event is specified by \a phase. - - \sa posF(), globalPosF(), angleDelta(), pixelDelta(), phase() + \obsolete + This constructor has been deprecated. */ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, @@ -888,31 +817,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, {} /*! - Constructs a wheel event object. - - The \a pos provides the location of the mouse cursor within the window. The - position in global coordinates is specified by \a globalPos. - - \a pixelDelta contains the scrolling distance in pixels on screen, while - \a angleDelta contains the wheel rotation distance. \a pixelDelta is - optional and can be null. - - The mouse and keyboard states at the time of the event are specified by - \a buttons and \a modifiers. - - For backwards compatibility, the event can also hold monodirectional wheel - event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the - direction. - - The scrolling phase of the event is specified by \a phase. - - If the wheel event comes from a physical mouse wheel, \a source is set to - Qt::MouseEventNotSynthesized. If it comes from a gesture detected by the - operating system, or from a non-mouse hardware device, such that \a pixelDelta is - directly related to finger movement, \a source is set to Qt::MouseEventSynthesizedBySystem. - If it comes from Qt, source would be set to Qt::MouseEventSynthesizedByQt. - - \sa posF(), globalPosF(), angleDelta(), pixelDelta(), phase() + \obsolete + This constructor has been deprecated. */ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, @@ -923,37 +829,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, {} /*! - Constructs a wheel event object. - - The \a pos provides the location of the mouse cursor - within the window. The position in global coordinates is specified - by \a globalPos. - - \a pixelDelta contains the scrolling distance in pixels on screen, while - \a angleDelta contains the wheel rotation distance. \a pixelDelta is - optional and can be null. - - The mouse and keyboard states at the time of the event are specified by - \a buttons and \a modifiers. - - For backwards compatibility, the event can also hold monodirectional wheel - event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the - direction. - - The scrolling phase of the event is specified by \a phase. - - If the wheel event comes from a physical mouse wheel, \a source is set to - Qt::MouseEventNotSynthesized. If it comes from a gesture detected by the - operating system, or from a non-mouse hardware device, such that \a - pixelDelta is directly related to finger movement, \a source is set to - Qt::MouseEventSynthesizedBySystem. If it comes from Qt, source would be set - to Qt::MouseEventSynthesizedByQt. - - If the system is configured to invert the delta values delivered with the - event (such as natural scrolling of the touchpad on OS X), \a inverted - should be \c true. Otherwise, \a inverted is \c false - - \sa posF(), globalPosF(), angleDelta(), pixelDelta(), phase() + \obsolete + This constructor has been deprecated. */ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, @@ -962,6 +839,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), src(source), invertedScrolling(inverted), ph(phase) {} +#endif // QT_DEPRECATED_SINCE(5, 14) /*! Constructs a wheel event object. @@ -990,7 +868,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, event (such as natural scrolling of the touchpad on macOS), \a inverted should be \c true. Otherwise, \a inverted is \c false - \sa posF(), globalPosF(), angleDelta(), pixelDelta(), phase() + \sa position(), globalPosition(), angleDelta(), pixelDelta(), phase(), inverted(), source() */ QWheelEvent::QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoint angleDelta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, @@ -1002,6 +880,12 @@ QWheelEvent::QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoi qt4D = (qt4O == Qt::Horizontal ? angleDelta.x() : angleDelta.y()); } +/*! + \internal +*/ +QWheelEvent::~QWheelEvent() +{ +} #endif // QT_CONFIG(wheelevent) /*! @@ -1061,87 +945,59 @@ QWheelEvent::QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoi /*! \fn QPoint QWheelEvent::pos() const + \obsolete - Returns the position of the mouse cursor relative to the widget - that received the event. - - If you move your widgets around in response to mouse events, - use globalPos() instead of this function. - - \sa x(), y(), globalPos() + This function has been deprecated, use position() instead. */ /*! \fn int QWheelEvent::x() const + \obsolete - Returns the x position of the mouse cursor, relative to the - widget that received the event. - - \sa y(), pos() + This function has been deprecated, use position() instead. */ /*! \fn int QWheelEvent::y() const + \obsolete - Returns the y position of the mouse cursor, relative to the - widget that received the event. - - \sa x(), pos() + This function has been deprecated, use position() instead. */ /*! \fn QPoint QWheelEvent::globalPos() const + \obsolete - Returns the global position of the mouse pointer \e{at the time - of the event}. This is important on asynchronous window systems - such as X11; whenever you move your widgets around in response to - mouse events, globalPos() can differ a lot from the current - cursor position returned by QCursor::pos(). - - \sa globalX(), globalY() + This function has been deprecated, use globalPosition() instead. */ /*! \fn int QWheelEvent::globalX() const + \obsolete - Returns the global x position of the mouse cursor at the time of - the event. - - \sa globalY(), globalPos() + This function has been deprecated, use globalPosition() instead. */ /*! \fn int QWheelEvent::globalY() const + \obsolete - Returns the global y position of the mouse cursor at the time of - the event. - - \sa globalX(), globalPos() + This function has been deprecated, use globalPosition() instead. */ /*! \fn const QPointF &QWheelEvent::posF() const + \obsolete - Returns the position of the mouse cursor relative to the widget - that received the event. - - If you move your widgets around in response to mouse events, - use globalPosF() instead of this function. - - \sa globalPosF() + This function has been deprecated, use position() instead. */ /*! \fn const QPointF &QWheelEvent::globalPosF() const + \obsolete - Returns the global position of the mouse pointer \e{at the time - of the event}. This is important on asynchronous window systems - such as X11; whenever you move your widgets around in response to - mouse events, globalPosF() can differ a lot from the current - cursor position returned by QCursor::pos(). - - \sa posF() + This function has been deprecated, use globalPosition() instead. */ /*! @@ -4074,8 +3930,10 @@ QDebug operator<<(QDebug dbg, const QEvent *e) dbg << "QWheelEvent(" << we->phase(); if (!we->pixelDelta().isNull() || !we->angleDelta().isNull()) dbg << ", pixelDelta=" << we->pixelDelta() << ", angleDelta=" << we->angleDelta(); +#if QT_DEPRECATED_SINCE(5, 14) else if (int qt4Delta = we->delta()) dbg << ", delta=" << qt4Delta << ", orientation=" << we->orientation(); +#endif dbg << ')'; } break; diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index eb0a6208a9..d110529927 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -175,24 +175,34 @@ class Q_GUI_EXPORT QWheelEvent : public QInputEvent public: enum { DefaultDeltasPerStep = 120 }; +#if QT_DEPRECATED_SINCE(5, 14) + // Actually deprecated since 5.0, in docs + QT_DEPRECATED_X("Use the last QWheelEvent constructor taking pixelDelta, angleDelta, phase, and inverted") QWheelEvent(const QPointF &pos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient = Qt::Vertical); + // Actually deprecated since 5.0, in docs + QT_DEPRECATED_X("Use the last QWheelEvent constructor taking pixelDelta, angleDelta, phase, and inverted") QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient = Qt::Vertical); + QT_DEPRECATED_X("Use the last QWheelEvent constructor taking pixelDelta, angleDelta, phase, and inverted") QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); + QT_DEPRECATED_X("Use the last QWheelEvent constructor taking pixelDelta, angleDelta, phase, and inverted") QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase); + QT_DEPRECATED_X("Use the last QWheelEvent constructor taking pixelDelta, angleDelta, phase, and inverted") QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source); + QT_DEPRECATED_X("Use the last QWheelEvent constructor taking pixelDelta, angleDelta, phase, and inverted") QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source, bool inverted); +#endif QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoint angleDelta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, @@ -203,19 +213,35 @@ public: inline QPoint pixelDelta() const { return pixelD; } inline QPoint angleDelta() const { return angleD; } +#if QT_DEPRECATED_SINCE(5, 14) + // Actually deprecated since 5.0, in docs + QT_DEPRECATED_X("Use angleDelta()") inline int delta() const { return qt4D; } + // Actually deprecated since 5.0, in docs + QT_DEPRECATED_X("Use angleDelta()") inline Qt::Orientation orientation() const { return qt4O; } - #ifndef QT_NO_INTEGER_EVENT_COORDINATES + QT_DEPRECATED_X("Use position()") inline QPoint pos() const { return p.toPoint(); } + QT_DEPRECATED_X("Use globalPosition()") inline QPoint globalPos() const { return g.toPoint(); } + QT_DEPRECATED_X("Use position()") inline int x() const { return int(p.x()); } + QT_DEPRECATED_X("Use position()") inline int y() const { return int(p.y()); } + QT_DEPRECATED_X("Use globalPosition()") inline int globalX() const { return int(g.x()); } + QT_DEPRECATED_X("Use globalPosition()") inline int globalY() const { return int(g.y()); } #endif + QT_DEPRECATED_X("Use position()") inline const QPointF &posF() const { return p; } + QT_DEPRECATED_X("Use globalPosition()") inline const QPointF &globalPosF() const { return g; } +#endif // QT_DEPRECATED_SINCE(5, 14) + + inline QPointF position() const { return p; } + inline QPointF globalPosition() const { return g; } inline Qt::MouseButtons buttons() const { return mouseState; } @@ -231,7 +257,7 @@ protected: QPoint angleD; int qt4D = 0; Qt::Orientation qt4O = Qt::Vertical; - Qt::MouseButtons mouseState; + Qt::MouseButtons mouseState = Qt::NoButton; uint _unused_ : 2; // Kept for binary compatibility uint src: 2; bool invertedScrolling : 1; diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index ceb5055a9d..426f2aeece 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2239,8 +2239,13 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh return; } +#if QT_DEPRECATED_SINCE(5, 14) QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, mouse_buttons, e->modifiers, e->phase, e->source, e->inverted); +#else + QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, + mouse_buttons, e->modifiers, e->phase, e->inverted, e->source); +#endif ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(window, &ev); #else diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index f1b01fbb4d..dec9e7a268 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -1293,8 +1293,15 @@ void QGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event) pos = d->mapToReceiver(pos, receiver); // Send mouse event. - QWheelEvent wheelEvent(pos.toPoint(), event->screenPos(), event->delta(), - event->buttons(), event->modifiers(), event->orientation()); + QPoint angleDelta; + if (event->orientation() == Qt::Horizontal) + angleDelta.setX(event->delta()); + else + angleDelta.setY(event->delta()); + // pixelDelta, inverted, scrollPhase and source from the original QWheelEvent + // were not preserved in the QGraphicsSceneWheelEvent unfortunately + QWheelEvent wheelEvent(pos, event->screenPos(), QPoint(), angleDelta, + event->buttons(), event->modifiers(), Qt::NoScrollPhase, false); QPointer<QWidget> focusWidget = d->widget->focusWidget(); extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); qt_sendSpontaneousEvent(receiver, &wheelEvent); diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 3ec9668cde..d5919eb55f 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -3426,12 +3426,13 @@ void QGraphicsView::wheelEvent(QWheelEvent *event) QGraphicsSceneWheelEvent wheelEvent(QEvent::GraphicsSceneWheel); wheelEvent.setWidget(viewport()); - wheelEvent.setScenePos(mapToScene(event->pos())); - wheelEvent.setScreenPos(event->globalPos()); + wheelEvent.setScenePos(mapToScene(event->position().toPoint())); + wheelEvent.setScreenPos(event->globalPosition().toPoint()); wheelEvent.setButtons(event->buttons()); wheelEvent.setModifiers(event->modifiers()); - wheelEvent.setDelta(event->delta()); - wheelEvent.setOrientation(event->orientation()); + const bool horizontal = qAbs(event->angleDelta().x()) > qAbs(event->angleDelta().y()); + wheelEvent.setDelta(horizontal ? event->angleDelta().x() : event->angleDelta().y()); + wheelEvent.setOrientation(horizontal ? Qt::Horizontal : Qt::Vertical); wheelEvent.setAccepted(false); QCoreApplication::sendEvent(d->scene, &wheelEvent); event->setAccepted(wheelEvent.isAccepted()); diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 25facd1484..0415dc4e56 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -810,14 +810,14 @@ void QListView::mouseReleaseEvent(QMouseEvent *e) void QListView::wheelEvent(QWheelEvent *e) { Q_D(QListView); - if (e->orientation() == Qt::Vertical) { + if (qAbs(e->angleDelta().y()) > qAbs(e->angleDelta().x())) { if (e->angleDelta().x() == 0 - && ((d->flow == TopToBottom && d->wrap) || (d->flow == LeftToRight && !d->wrap)) - && d->vbar->minimum() == 0 && d->vbar->maximum() == 0) { + && ((d->flow == TopToBottom && d->wrap) || (d->flow == LeftToRight && !d->wrap)) + && d->vbar->minimum() == 0 && d->vbar->maximum() == 0) { QPoint pixelDelta(e->pixelDelta().y(), e->pixelDelta().x()); QPoint angleDelta(e->angleDelta().y(), e->angleDelta().x()); - QWheelEvent hwe(e->pos(), e->globalPos(), pixelDelta, angleDelta, e->delta(), - Qt::Horizontal, e->buttons(), e->modifiers(), e->phase(), e->source(), e->inverted()); + QWheelEvent hwe(e->position(), e->globalPosition(), pixelDelta, angleDelta, + e->buttons(), e->modifiers(), e->phase(), e->inverted(), e->source()); if (e->spontaneous()) qt_sendSpontaneousEvent(d->hbar, &hwe); else diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index c922aecceb..7feb18e839 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3240,13 +3240,18 @@ bool QApplication::notify(QObject *receiver, QEvent *e) if (spontaneous && phase == Qt::ScrollBegin) QApplicationPrivate::wheel_widget = nullptr; - const QPoint &relpos = wheel->pos(); + QPoint relpos = wheel->position().toPoint(); if (spontaneous && (phase == Qt::NoScrollPhase || phase == Qt::ScrollUpdate)) QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, relpos); +#if QT_DEPRECATED_SINCE(5, 14) QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), wheel->modifiers(), phase, wheel->source(), wheel->inverted()); +#else + QWheelEvent we(relpos, wheel->globalPosition(), wheel->pixelDelta(), wheel->angleDelta(), wheel->buttons(), + wheel->modifiers(), phase, wheel->inverted(), wheel->source()); +#endif we.setTimestamp(wheel->timestamp()); bool eventAccepted; do { @@ -3281,9 +3286,14 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // is set. Since it accepted the wheel event previously, we continue // sending those events until we get a ScrollEnd, which signifies // the end of the natural scrolling sequence. - const QPoint &relpos = QApplicationPrivate::wheel_widget->mapFromGlobal(wheel->globalPos()); + const QPoint &relpos = QApplicationPrivate::wheel_widget->mapFromGlobal(wheel->globalPosition().toPoint()); +#if QT_DEPRECATED_SINCE(5, 0) QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), wheel->modifiers(), wheel->phase(), wheel->source()); +#else + QWheelEvent we(relpos, wheel->globalPosition(), wheel->pixelDelta(), wheel->angleDelta(), wheel->buttons(), + wheel->modifiers(), wheel->phase(), wheel->inverted(), wheel->source()); +#endif we.setTimestamp(wheel->timestamp()); we.spont = true; we.ignore(); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index ba10083829..5537ff497a 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -828,14 +828,14 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) return; QWidget *rootWidget = m_widget; - QPoint pos = event->pos(); + QPoint pos = event->position().toPoint(); // Use proper popup window for wheel event. Some QPA sends the wheel // event to the root menu, so redirect it to the proper popup window. QWidget *activePopupWidget = QApplication::activePopupWidget(); if (activePopupWidget && activePopupWidget != m_widget) { rootWidget = activePopupWidget; - pos = rootWidget->mapFromGlobal(event->globalPos()); + pos = rootWidget->mapFromGlobal(event->globalPosition().toPoint()); } // which child should have it? @@ -846,7 +846,12 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) QPoint mapped = widget->mapFrom(rootWidget, pos); +#if QT_DEPRECATED_SINCE(5, 0) QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted()); +#else + QWheelEvent translated(QPointF(mapped), event->globalPosition(), event->pixelDelta(), event->angleDelta(), + event->buttons(), event->modifiers(), event->phase(), event->inverted(), event->source()); +#endif translated.setTimestamp(event->timestamp()); QGuiApplication::forwardEvent(widget, &translated, event); } diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index b9e0d3280f..8f50ec1584 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1324,7 +1324,7 @@ void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e) void QAbstractScrollArea::wheelEvent(QWheelEvent *e) { Q_D(QAbstractScrollArea); - if (e->orientation() == Qt::Horizontal) + if (qAbs(e->angleDelta().x()) > qAbs(e->angleDelta().y())) QCoreApplication::sendEvent(d->hbar, e); else QCoreApplication::sendEvent(d->vbar, e); diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index 2172ebc99c..1c1aec6035 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -764,10 +764,11 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) { Q_D(QAbstractSlider); e->ignore(); - int delta = e->delta(); + bool vertical = bool(e->angleDelta().y()); + int delta = vertical ? e->angleDelta().y() : e->angleDelta().x(); if (e->inverted()) delta = -delta; - if (d->scrollByDelta(e->orientation(), e->modifiers(), delta)) + if (d->scrollByDelta(vertical ? Qt::Vertical : Qt::Horizontal, e->modifiers(), delta)) e->accept(); } diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 510b34cb18..f07b42c181 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -1418,7 +1418,7 @@ void QCalendarView::keyPressEvent(QKeyEvent *event) #if QT_CONFIG(wheelevent) void QCalendarView::wheelEvent(QWheelEvent *event) { - const int numDegrees = event->delta() / 8; + const int numDegrees = event->angleDelta().y() / 8; const int numSteps = numDegrees / 15; const QModelIndex index = currentIndex(); QDate currentDate = static_cast<QCalendarModel*>(model())->dateForCell(index.row(), index.column()); diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 90d55f9688..83c472b51a 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -3378,12 +3378,13 @@ void QComboBox::wheelEvent(QWheelEvent *e) !d->viewContainer()->isVisible()) { const int rowCount = count(); int newIndex = currentIndex(); + int delta = e->angleDelta().y(); - if (e->delta() > 0) { + if (delta > 0) { newIndex--; while ((newIndex >= 0) && !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled)) newIndex--; - } else if (e->delta() < 0) { + } else if (delta < 0) { newIndex++; while (newIndex < rowCount && !(d->model->index(newIndex, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled)) newIndex++; diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 72653b377d..7ec33acbbf 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -2847,8 +2847,8 @@ void QMenu::paintEvent(QPaintEvent *e) void QMenu::wheelEvent(QWheelEvent *e) { Q_D(QMenu); - if (d->scroll && rect().contains(e->pos())) - d->scrollMenu(e->delta() > 0 ? + if (d->scroll && rect().contains(e->position().toPoint())) + d->scrollMenu(e->angleDelta().y() > 0 ? QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown); } #endif diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index b4168268a0..08d771a27a 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -497,16 +497,14 @@ bool QScrollBar::event(QEvent *event) void QScrollBar::wheelEvent(QWheelEvent *event) { event->ignore(); - int delta = event->delta(); // scrollbar is a special case - in vertical mode it reaches minimum // value in the upper position, however QSlider's minimum value is on - // the bottom. So we need to invert a value, but since the scrollbar is - // inverted by default, we need to inverse the delta value for the + // the bottom. So we need to invert the value, but since the scrollbar is + // inverted by default, we need to invert the delta value only for the // horizontal orientation. - if (event->orientation() == Qt::Horizontal) - delta = -delta; + int delta = (orientation() == Qt::Horizontal ? -event->angleDelta().x() : event->angleDelta().y()); Q_D(QScrollBar); - if (d->scrollByDelta(event->orientation(), event->modifiers(), delta)) + if (d->scrollByDelta(orientation(), event->modifiers(), delta)) event->accept(); if (event->phase() == Qt::ScrollBegin) diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index f6f56c12d1..1be1729684 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -2210,7 +2210,9 @@ void QTabBar::wheelEvent(QWheelEvent *event) { #ifndef Q_OS_MAC Q_D(QTabBar); - int offset = event->delta() > 0 ? -1 : 1; + int delta = (qAbs(event->angleDelta().x()) > qAbs(event->angleDelta().y()) ? + event->angleDelta().x() : event->angleDelta().y()); + int offset = delta > 0 ? -1 : 1; d->setCurrentNextEnabledIndex(offset); QWidget::wheelEvent(event); #else diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 52cc7ed128..7a385a230e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -2219,7 +2219,7 @@ void tst_QGraphicsView::wheelEvent() { QWheelEvent event(view.mapFromScene(widget->boundingRect().center()), view.mapToGlobal(view.mapFromScene(widget->boundingRect().center())), - 120, 0, 0, Qt::Horizontal); + QPoint(), QPoint(120, 0), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QApplication::sendEvent(view.viewport(), &event); QCOMPARE(scene.orientation, Qt::Horizontal); } @@ -2228,7 +2228,7 @@ void tst_QGraphicsView::wheelEvent() { QWheelEvent event(view.mapFromScene(widget->boundingRect().center()), view.mapToGlobal(view.mapFromScene(widget->boundingRect().center())), - 120, 0, 0, Qt::Vertical); + QPoint(), QPoint(0, 120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QApplication::sendEvent(view.viewport(), &event); QCOMPARE(scene.orientation, Qt::Vertical); } diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 0b828b8484..3a60b3b7c6 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -2516,9 +2516,9 @@ void tst_QListView::horizontalScrollingByVerticalWheelEvents() QPoint globalPos = lv.geometry().center(); QPoint pos = lv.viewport()->geometry().center(); - QWheelEvent wheelDownEvent(pos, globalPos, QPoint(0, 0), QPoint(0, -120), -120, Qt::Vertical, 0, 0); - QWheelEvent wheelUpEvent(pos, globalPos, QPoint(0, 0), QPoint(0, 120), 120, Qt::Vertical, 0, 0); - QWheelEvent wheelLeftDownEvent(pos, globalPos, QPoint(0, 0), QPoint(120, -120), -120, Qt::Vertical, 0, 0); + QWheelEvent wheelDownEvent(pos, globalPos, QPoint(0, 0), QPoint(0, -120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); + QWheelEvent wheelUpEvent(pos, globalPos, QPoint(0, 0), QPoint(0, 120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); + QWheelEvent wheelLeftDownEvent(pos, globalPos, QPoint(0, 0), QPoint(120, -120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); int hValue = lv.horizontalScrollBar()->value(); QApplication::sendEvent(lv.viewport(), &wheelDownEvent); diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index bf87408056..6bbb30a6db 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -4074,8 +4074,10 @@ void tst_QTableView::mouseWheel() view.verticalScrollBar()->setValue(10); QPoint pos = view.viewport()->geometry().center(); - QWheelEvent verticalEvent(pos, delta, 0, 0, Qt::Vertical); - QWheelEvent horizontalEvent(pos, delta, 0, 0, Qt::Horizontal); + QWheelEvent verticalEvent(pos, view.mapToGlobal(pos), QPoint(), QPoint(0, delta), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); + QWheelEvent horizontalEvent(pos, view.mapToGlobal(pos), QPoint(), QPoint(delta, 0), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QApplication::sendEvent(view.viewport(), &horizontalEvent); QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 15); QApplication::sendEvent(view.viewport(), &verticalEvent); @@ -4350,7 +4352,9 @@ void tst_QTableView::taskQTBUG_5237_wheelEventOnHeader() int sbValueBefore = view.verticalScrollBar()->value(); QHeaderView *header = view.verticalHeader(); QTest::mouseMove(header); - QWheelEvent wheelEvent(header->geometry().center(), -720, 0, 0); + QPoint pos = header->geometry().center(); + QWheelEvent wheelEvent(pos, header->viewport()->mapToGlobal(pos), QPoint(), QPoint(0, -720), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QApplication::sendEvent(header->viewport(), &wheelEvent); int sbValueAfter = view.verticalScrollBar()->value(); QVERIFY(sbValueBefore != sbValueAfter); diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index d8fbb8e041..f77efe036a 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -1662,8 +1662,12 @@ void tst_QAbstractSlider::wheelEvent() slider->setOrientation(sliderOrientation); Qt::KeyboardModifier k = withModifiers ? Qt::ControlModifier : Qt::NoModifier; - QWheelEvent event(slider->rect().bottomRight() + distanceFromBottomRight, WHEEL_DELTA * deltaMultiple, - Qt::NoButton, k, wheelOrientation); + + const QPoint wheelPoint = slider->rect().bottomRight() + distanceFromBottomRight; + const QPoint angleDelta(wheelOrientation == Qt::Horizontal ? WHEEL_DELTA * deltaMultiple : 0, + wheelOrientation == Qt::Vertical ? WHEEL_DELTA * deltaMultiple : 0); + QWheelEvent event(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), angleDelta, + Qt::NoButton, k, Qt::NoScrollPhase, false); QVERIFY(applicationInstance->sendEvent(slider,&event)); #ifdef Q_OS_MAC QEXPECT_FAIL("Normal data page", "QTBUG-23679", Continue); @@ -1674,8 +1678,8 @@ void tst_QAbstractSlider::wheelEvent() slider->setSliderPosition(initialSliderPosition); k = withModifiers ? Qt::ShiftModifier : Qt::NoModifier; - event = QWheelEvent(slider->rect().bottomRight() + distanceFromBottomRight, WHEEL_DELTA * deltaMultiple, - Qt::NoButton, k, wheelOrientation); + event = QWheelEvent(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), angleDelta, + Qt::NoButton, k, Qt::NoScrollPhase, false); QSignalSpy spy1(slider, SIGNAL(actionTriggered(int))); QSignalSpy spy2(slider, SIGNAL(valueChanged(int))); QVERIFY(applicationInstance->sendEvent(slider,&event)); @@ -1715,16 +1719,16 @@ void tst_QAbstractSlider::fineGrainedWheelEvent() slider->setSliderPosition(0); const int singleStepDelta = invertedControls ? (-WHEEL_DELTA / 3) : (WHEEL_DELTA / 3); - - QWheelEvent eventDown(slider->rect().bottomRight(), singleStepDelta / 2, - Qt::NoButton, Qt::NoModifier, Qt::Vertical); + const QPoint wheelPoint = slider->rect().bottomRight(); + QWheelEvent eventDown(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), QPoint(0, singleStepDelta / 2), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); QCOMPARE(slider->sliderPosition(), 0); QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); QCOMPARE(slider->sliderPosition(), 1); - QWheelEvent eventUp(slider->rect().bottomRight(), -singleStepDelta / 2, - Qt::NoButton, Qt::NoModifier, Qt::Vertical); + QWheelEvent eventUp(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), QPoint(0, -singleStepDelta / 2), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); QCOMPARE(slider->sliderPosition(), 1); QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index a576770811..8a46211714 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2102,7 +2102,9 @@ void tst_QComboBox::mouseWheel() box.setEditable(i==0?false:true); box.setCurrentIndex(startIndex); - QWheelEvent event = QWheelEvent(box.rect().bottomRight() , WHEEL_DELTA * wheelDirection, Qt::NoButton, Qt::NoModifier); + const QPoint wheelPoint = box.rect().bottomRight(); + QWheelEvent event(wheelPoint, box.mapToGlobal(wheelPoint), QPoint(), QPoint(0, WHEEL_DELTA * wheelDirection), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QVERIFY(applicationInstance->sendEvent(&box,&event)); QCOMPARE(box.currentIndex(), expectedIndex); @@ -2131,7 +2133,9 @@ void tst_QComboBox::popupWheelHandling() comboBox->showPopup(); QTRY_VERIFY(comboBox->view() && comboBox->view()->isVisible()); const QPoint popupPos = comboBox->view()->pos(); - QWheelEvent event(QPointF(10, 10), WHEEL_DELTA, Qt::NoButton, Qt::NoModifier); + const QPoint wheelPoint(10, 10); + QWheelEvent event(wheelPoint, scrollArea.mapToGlobal(wheelPoint), QPoint(), QPoint(0, WHEEL_DELTA), + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); QVERIFY(QCoreApplication::sendEvent(scrollArea.windowHandle(), &event)); QCoreApplication::processEvents(); QVERIFY(comboBox->view()->isVisible()); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index cd045e476c..810f081b73 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -3141,7 +3141,6 @@ void tst_QDateTimeEdit::wheelEvent_data() { #if QT_CONFIG(wheelevent) QTest::addColumn<QPoint>("angleDelta"); - QTest::addColumn<int>("qt4Delta"); QTest::addColumn<int>("stepModifier"); QTest::addColumn<Qt::KeyboardModifiers>("modifiers"); QTest::addColumn<Qt::MouseEventSource>("source"); @@ -3255,7 +3254,6 @@ void tst_QDateTimeEdit::wheelEvent_data() modifierName.latin1(), sourceName.latin1()) << angleDelta - << units << static_cast<int>(stepModifier) << modifiers << source @@ -3277,7 +3275,6 @@ void tst_QDateTimeEdit::wheelEvent() { #if QT_CONFIG(wheelevent) QFETCH(QPoint, angleDelta); - QFETCH(int, qt4Delta); QFETCH(int, stepModifier); QFETCH(Qt::KeyboardModifiers, modifiers); QFETCH(Qt::MouseEventSource, source); @@ -3294,9 +3291,8 @@ void tst_QDateTimeEdit::wheelEvent() style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier); edit.setStyle(style.data()); - QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, qt4Delta, - Qt::Vertical, Qt::NoButton, modifiers, Qt::NoScrollPhase, - source); + QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, + Qt::NoButton, modifiers, Qt::NoScrollPhase, false, source); QCOMPARE(edit.date(), startDate); for (QDate expected : expectedDates) { diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index a20b5568da..fed4d6f147 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -1377,7 +1377,6 @@ void tst_QDoubleSpinBox::wheelEvents_data() { #if QT_CONFIG(wheelevent) QTest::addColumn<QPoint>("angleDelta"); - QTest::addColumn<int>("qt4Delta"); QTest::addColumn<int>("stepModifier"); QTest::addColumn<Qt::KeyboardModifiers>("modifier"); QTest::addColumn<Qt::MouseEventSource>("source"); @@ -1476,7 +1475,6 @@ void tst_QDoubleSpinBox::wheelEvents_data() modifierName.latin1(), sourceName.latin1()) << angleDelta - << units << static_cast<int>(stepModifier) << modifiers << source @@ -1496,7 +1494,6 @@ void tst_QDoubleSpinBox::wheelEvents() { #if QT_CONFIG(wheelevent) QFETCH(QPoint, angleDelta); - QFETCH(int, qt4Delta); QFETCH(int, stepModifier); QFETCH(Qt::KeyboardModifiers, modifier); QFETCH(Qt::MouseEventSource, source); @@ -1512,9 +1509,8 @@ void tst_QDoubleSpinBox::wheelEvents() style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier); spinBox.setStyle(style.data()); - QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, qt4Delta, - Qt::Vertical, Qt::NoButton, modifier, Qt::NoScrollPhase, - source); + QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, + Qt::NoButton, modifier, Qt::NoScrollPhase, source); for (int expected : expectedValues) { qApp->sendEvent(&spinBox, &event); QCOMPARE(spinBox.value(), expected); diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index 278f5cdd68..339ff293f4 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -151,8 +151,11 @@ void tst_QScrollBar::QTBUG_27308() testWidget.setValue(testWidget.minimum()); testWidget.setEnabled(false); - QWheelEvent event(testWidget.rect().center(), - -WHEEL_DELTA, Qt::NoButton, Qt::NoModifier, testWidget.orientation()); + const QPoint wheelPoint = testWidget.rect().center(); + const QPoint angleDelta(testWidget.orientation() == Qt::Horizontal ? -WHEEL_DELTA : 0, + testWidget.orientation() == Qt::Vertical ? -WHEEL_DELTA : 0); + QWheelEvent event(wheelPoint, testWidget.mapToGlobal(wheelPoint), QPoint(), angleDelta, + Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); qApp->sendEvent(&testWidget, &event); QCOMPARE(testWidget.value(), testWidget.minimum()); } diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 3dd29b0214..cfa8db1fcc 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -1331,7 +1331,6 @@ void tst_QSpinBox::wheelEvents_data() { #if QT_CONFIG(wheelevent) QTest::addColumn<QPoint>("angleDelta"); - QTest::addColumn<int>("qt4Delta"); QTest::addColumn<int>("stepModifier"); QTest::addColumn<Qt::KeyboardModifiers>("modifier"); QTest::addColumn<Qt::MouseEventSource>("source"); @@ -1430,7 +1429,6 @@ void tst_QSpinBox::wheelEvents_data() modifierName.latin1(), sourceName.latin1()) << angleDelta - << units << static_cast<int>(stepModifier) << modifiers << source @@ -1450,7 +1448,6 @@ void tst_QSpinBox::wheelEvents() { #if QT_CONFIG(wheelevent) QFETCH(QPoint, angleDelta); - QFETCH(int, qt4Delta); QFETCH(int, stepModifier); QFETCH(Qt::KeyboardModifiers, modifier); QFETCH(Qt::MouseEventSource, source); @@ -1466,9 +1463,8 @@ void tst_QSpinBox::wheelEvents() style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier); spinBox.setStyle(style.data()); - QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, qt4Delta, - Qt::Vertical, Qt::NoButton, modifier, Qt::NoScrollPhase, - source); + QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, + Qt::NoButton, modifier, Qt::NoScrollPhase, source); for (int expected : expectedValues) { qApp->sendEvent(&spinBox, &event); QCOMPARE(spinBox.value(), expected); diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 81682dc027..c2cf31bfa4 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -2669,12 +2669,14 @@ void tst_QTextEdit::wheelEvent() ed.setReadOnly(true); float defaultFontSize = ed.font().pointSizeF(); - QWheelEvent wheelUp(QPointF(), QPointF(), QPoint(), QPoint(0, 120), 120, Qt::Vertical, Qt::NoButton, Qt::ControlModifier); + QWheelEvent wheelUp(QPointF(), QPointF(), QPoint(), QPoint(0, 120), + Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, Qt::MouseEventNotSynthesized); ed.wheelEvent(&wheelUp); QCOMPARE(defaultFontSize + 1, ed.font().pointSizeF()); - QWheelEvent wheelHalfDown(QPointF(), QPointF(), QPoint(), QPoint(0, -60), -60, Qt::Vertical, Qt::NoButton, Qt::ControlModifier); + QWheelEvent wheelHalfDown(QPointF(), QPointF(), QPoint(), QPoint(0, -60), + Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, Qt::MouseEventNotSynthesized); ed.wheelEvent(&wheelHalfDown); QCOMPARE(defaultFontSize + 0.5, ed.font().pointSizeF()); |