Finish deprecating obsolete members of QWheelEvent
In Qt 5.0, delta() and orientation() were already marked obsolete, but Widgets and tests have kept on depending on them all this time. We now start using alternative API so they can really be deprecated. All constructors except the newest one are also deprecated. The plan is for all events from pointing devices to have QPointF position() and globalPosition(), so we deprecate the other position accessors. [ChangeLog][QtGui] Obsolete constructors and accessors in QWheelEvent now have proper deprecation macros. What is left is intended to be compatible with planned changes in Qt 6. Change-Id: I26250dc90922b60a6ed20d7f65f38019da3e139e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
0a724ac74c
commit
7d29807296
@ -754,31 +754,15 @@ QHoverEvent::~QHoverEvent()
|
|||||||
\fn Qt::Orientation QWheelEvent::orientation() const
|
\fn Qt::Orientation QWheelEvent::orientation() const
|
||||||
\obsolete
|
\obsolete
|
||||||
|
|
||||||
Returns the wheel's orientation.
|
|
||||||
|
|
||||||
Use angleDelta() instead.
|
Use angleDelta() instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if QT_CONFIG(wheelevent)
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 14)
|
||||||
/*!
|
/*!
|
||||||
\obsolete
|
\obsolete
|
||||||
Constructs a wheel event object.
|
This constructor has been deprecated.
|
||||||
|
|
||||||
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()
|
|
||||||
*/
|
*/
|
||||||
#if QT_CONFIG(wheelevent)
|
|
||||||
QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
|
QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
||||||
Qt::Orientation orient)
|
Qt::Orientation orient)
|
||||||
@ -792,27 +776,9 @@ QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
|
|||||||
angleD = QPoint(delta, 0);
|
angleD = QPoint(delta, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\internal
|
|
||||||
*/
|
|
||||||
QWheelEvent::~QWheelEvent()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\obsolete
|
\obsolete
|
||||||
Constructs a wheel event object.
|
This constructor has been deprecated.
|
||||||
|
|
||||||
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()
|
|
||||||
*/
|
*/
|
||||||
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
|
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
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.
|
\obsolete
|
||||||
|
This constructor has been deprecated.
|
||||||
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()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
|
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.
|
\obsolete
|
||||||
|
This constructor has been deprecated.
|
||||||
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()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
|
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.
|
\obsolete
|
||||||
|
This constructor has been deprecated.
|
||||||
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()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
|
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.
|
\obsolete
|
||||||
|
This constructor has been deprecated.
|
||||||
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()
|
|
||||||
*/
|
*/
|
||||||
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
|
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
|
||||||
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
|
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),
|
angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), src(source),
|
||||||
invertedScrolling(inverted), ph(phase)
|
invertedScrolling(inverted), ph(phase)
|
||||||
{}
|
{}
|
||||||
|
#endif // QT_DEPRECATED_SINCE(5, 14)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a wheel event object.
|
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
|
event (such as natural scrolling of the touchpad on macOS), \a inverted
|
||||||
should be \c true. Otherwise, \a inverted is \c false
|
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,
|
QWheelEvent::QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoint angleDelta,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase,
|
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());
|
qt4D = (qt4O == Qt::Horizontal ? angleDelta.x() : angleDelta.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
*/
|
||||||
|
QWheelEvent::~QWheelEvent()
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif // QT_CONFIG(wheelevent)
|
#endif // QT_CONFIG(wheelevent)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1061,87 +945,59 @@ QWheelEvent::QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoi
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QPoint QWheelEvent::pos() const
|
\fn QPoint QWheelEvent::pos() const
|
||||||
|
\obsolete
|
||||||
|
|
||||||
Returns the position of the mouse cursor relative to the widget
|
This function has been deprecated, use position() instead.
|
||||||
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()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn int QWheelEvent::x() const
|
\fn int QWheelEvent::x() const
|
||||||
|
\obsolete
|
||||||
|
|
||||||
Returns the x position of the mouse cursor, relative to the
|
This function has been deprecated, use position() instead.
|
||||||
widget that received the event.
|
|
||||||
|
|
||||||
\sa y(), pos()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn int QWheelEvent::y() const
|
\fn int QWheelEvent::y() const
|
||||||
|
\obsolete
|
||||||
|
|
||||||
Returns the y position of the mouse cursor, relative to the
|
This function has been deprecated, use position() instead.
|
||||||
widget that received the event.
|
|
||||||
|
|
||||||
\sa x(), pos()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QPoint QWheelEvent::globalPos() const
|
\fn QPoint QWheelEvent::globalPos() const
|
||||||
|
\obsolete
|
||||||
|
|
||||||
Returns the global position of the mouse pointer \e{at the time
|
This function has been deprecated, use globalPosition() instead.
|
||||||
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()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn int QWheelEvent::globalX() const
|
\fn int QWheelEvent::globalX() const
|
||||||
|
\obsolete
|
||||||
|
|
||||||
Returns the global x position of the mouse cursor at the time of
|
This function has been deprecated, use globalPosition() instead.
|
||||||
the event.
|
|
||||||
|
|
||||||
\sa globalY(), globalPos()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn int QWheelEvent::globalY() const
|
\fn int QWheelEvent::globalY() const
|
||||||
|
\obsolete
|
||||||
|
|
||||||
Returns the global y position of the mouse cursor at the time of
|
This function has been deprecated, use globalPosition() instead.
|
||||||
the event.
|
|
||||||
|
|
||||||
\sa globalX(), globalPos()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn const QPointF &QWheelEvent::posF() const
|
\fn const QPointF &QWheelEvent::posF() const
|
||||||
|
\obsolete
|
||||||
|
|
||||||
Returns the position of the mouse cursor relative to the widget
|
This function has been deprecated, use position() instead.
|
||||||
that received the event.
|
|
||||||
|
|
||||||
If you move your widgets around in response to mouse events,
|
|
||||||
use globalPosF() instead of this function.
|
|
||||||
|
|
||||||
\sa globalPosF()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn const QPointF &QWheelEvent::globalPosF() const
|
\fn const QPointF &QWheelEvent::globalPosF() const
|
||||||
|
\obsolete
|
||||||
|
|
||||||
Returns the global position of the mouse pointer \e{at the time
|
This function has been deprecated, use globalPosition() instead.
|
||||||
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()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -4074,8 +3930,10 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
|
|||||||
dbg << "QWheelEvent(" << we->phase();
|
dbg << "QWheelEvent(" << we->phase();
|
||||||
if (!we->pixelDelta().isNull() || !we->angleDelta().isNull())
|
if (!we->pixelDelta().isNull() || !we->angleDelta().isNull())
|
||||||
dbg << ", pixelDelta=" << we->pixelDelta() << ", angleDelta=" << we->angleDelta();
|
dbg << ", pixelDelta=" << we->pixelDelta() << ", angleDelta=" << we->angleDelta();
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 14)
|
||||||
else if (int qt4Delta = we->delta())
|
else if (int qt4Delta = we->delta())
|
||||||
dbg << ", delta=" << qt4Delta << ", orientation=" << we->orientation();
|
dbg << ", delta=" << qt4Delta << ", orientation=" << we->orientation();
|
||||||
|
#endif
|
||||||
dbg << ')';
|
dbg << ')';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -175,24 +175,34 @@ class Q_GUI_EXPORT QWheelEvent : public QInputEvent
|
|||||||
public:
|
public:
|
||||||
enum { DefaultDeltasPerStep = 120 };
|
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,
|
QWheelEvent(const QPointF &pos, int delta,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
||||||
Qt::Orientation orient = Qt::Vertical);
|
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,
|
QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
||||||
Qt::Orientation orient = Qt::Vertical);
|
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,
|
QWheelEvent(const QPointF &pos, const QPointF& globalPos,
|
||||||
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
|
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
|
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,
|
QWheelEvent(const QPointF &pos, const QPointF& globalPos,
|
||||||
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
|
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase);
|
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,
|
QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pixelDelta, QPoint angleDelta,
|
||||||
int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons,
|
int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons,
|
||||||
Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source);
|
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,
|
QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pixelDelta, QPoint angleDelta,
|
||||||
int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons,
|
int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons,
|
||||||
Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source, bool inverted);
|
Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source, bool inverted);
|
||||||
|
#endif
|
||||||
|
|
||||||
QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoint angleDelta,
|
QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoint angleDelta,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase,
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase,
|
||||||
@ -203,19 +213,35 @@ public:
|
|||||||
inline QPoint pixelDelta() const { return pixelD; }
|
inline QPoint pixelDelta() const { return pixelD; }
|
||||||
inline QPoint angleDelta() const { return angleD; }
|
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; }
|
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; }
|
inline Qt::Orientation orientation() const { return qt4O; }
|
||||||
|
|
||||||
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||||
|
QT_DEPRECATED_X("Use position()")
|
||||||
inline QPoint pos() const { return p.toPoint(); }
|
inline QPoint pos() const { return p.toPoint(); }
|
||||||
|
QT_DEPRECATED_X("Use globalPosition()")
|
||||||
inline QPoint globalPos() const { return g.toPoint(); }
|
inline QPoint globalPos() const { return g.toPoint(); }
|
||||||
|
QT_DEPRECATED_X("Use position()")
|
||||||
inline int x() const { return int(p.x()); }
|
inline int x() const { return int(p.x()); }
|
||||||
|
QT_DEPRECATED_X("Use position()")
|
||||||
inline int y() const { return int(p.y()); }
|
inline int y() const { return int(p.y()); }
|
||||||
|
QT_DEPRECATED_X("Use globalPosition()")
|
||||||
inline int globalX() const { return int(g.x()); }
|
inline int globalX() const { return int(g.x()); }
|
||||||
|
QT_DEPRECATED_X("Use globalPosition()")
|
||||||
inline int globalY() const { return int(g.y()); }
|
inline int globalY() const { return int(g.y()); }
|
||||||
#endif
|
#endif
|
||||||
|
QT_DEPRECATED_X("Use position()")
|
||||||
inline const QPointF &posF() const { return p; }
|
inline const QPointF &posF() const { return p; }
|
||||||
|
QT_DEPRECATED_X("Use globalPosition()")
|
||||||
inline const QPointF &globalPosF() const { return g; }
|
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; }
|
inline Qt::MouseButtons buttons() const { return mouseState; }
|
||||||
|
|
||||||
@ -231,7 +257,7 @@ protected:
|
|||||||
QPoint angleD;
|
QPoint angleD;
|
||||||
int qt4D = 0;
|
int qt4D = 0;
|
||||||
Qt::Orientation qt4O = Qt::Vertical;
|
Qt::Orientation qt4O = Qt::Vertical;
|
||||||
Qt::MouseButtons mouseState;
|
Qt::MouseButtons mouseState = Qt::NoButton;
|
||||||
uint _unused_ : 2; // Kept for binary compatibility
|
uint _unused_ : 2; // Kept for binary compatibility
|
||||||
uint src: 2;
|
uint src: 2;
|
||||||
bool invertedScrolling : 1;
|
bool invertedScrolling : 1;
|
||||||
|
@ -2239,8 +2239,13 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 14)
|
||||||
QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation,
|
QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation,
|
||||||
mouse_buttons, e->modifiers, e->phase, e->source, e->inverted);
|
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);
|
ev.setTimestamp(e->timestamp);
|
||||||
QGuiApplication::sendSpontaneousEvent(window, &ev);
|
QGuiApplication::sendSpontaneousEvent(window, &ev);
|
||||||
#else
|
#else
|
||||||
|
@ -1293,8 +1293,15 @@ void QGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
|
|||||||
pos = d->mapToReceiver(pos, receiver);
|
pos = d->mapToReceiver(pos, receiver);
|
||||||
|
|
||||||
// Send mouse event.
|
// Send mouse event.
|
||||||
QWheelEvent wheelEvent(pos.toPoint(), event->screenPos(), event->delta(),
|
QPoint angleDelta;
|
||||||
event->buttons(), event->modifiers(), event->orientation());
|
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();
|
QPointer<QWidget> focusWidget = d->widget->focusWidget();
|
||||||
extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
|
extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
|
||||||
qt_sendSpontaneousEvent(receiver, &wheelEvent);
|
qt_sendSpontaneousEvent(receiver, &wheelEvent);
|
||||||
|
@ -3426,12 +3426,13 @@ void QGraphicsView::wheelEvent(QWheelEvent *event)
|
|||||||
|
|
||||||
QGraphicsSceneWheelEvent wheelEvent(QEvent::GraphicsSceneWheel);
|
QGraphicsSceneWheelEvent wheelEvent(QEvent::GraphicsSceneWheel);
|
||||||
wheelEvent.setWidget(viewport());
|
wheelEvent.setWidget(viewport());
|
||||||
wheelEvent.setScenePos(mapToScene(event->pos()));
|
wheelEvent.setScenePos(mapToScene(event->position().toPoint()));
|
||||||
wheelEvent.setScreenPos(event->globalPos());
|
wheelEvent.setScreenPos(event->globalPosition().toPoint());
|
||||||
wheelEvent.setButtons(event->buttons());
|
wheelEvent.setButtons(event->buttons());
|
||||||
wheelEvent.setModifiers(event->modifiers());
|
wheelEvent.setModifiers(event->modifiers());
|
||||||
wheelEvent.setDelta(event->delta());
|
const bool horizontal = qAbs(event->angleDelta().x()) > qAbs(event->angleDelta().y());
|
||||||
wheelEvent.setOrientation(event->orientation());
|
wheelEvent.setDelta(horizontal ? event->angleDelta().x() : event->angleDelta().y());
|
||||||
|
wheelEvent.setOrientation(horizontal ? Qt::Horizontal : Qt::Vertical);
|
||||||
wheelEvent.setAccepted(false);
|
wheelEvent.setAccepted(false);
|
||||||
QCoreApplication::sendEvent(d->scene, &wheelEvent);
|
QCoreApplication::sendEvent(d->scene, &wheelEvent);
|
||||||
event->setAccepted(wheelEvent.isAccepted());
|
event->setAccepted(wheelEvent.isAccepted());
|
||||||
|
@ -810,14 +810,14 @@ void QListView::mouseReleaseEvent(QMouseEvent *e)
|
|||||||
void QListView::wheelEvent(QWheelEvent *e)
|
void QListView::wheelEvent(QWheelEvent *e)
|
||||||
{
|
{
|
||||||
Q_D(QListView);
|
Q_D(QListView);
|
||||||
if (e->orientation() == Qt::Vertical) {
|
if (qAbs(e->angleDelta().y()) > qAbs(e->angleDelta().x())) {
|
||||||
if (e->angleDelta().x() == 0
|
if (e->angleDelta().x() == 0
|
||||||
&& ((d->flow == TopToBottom && d->wrap) || (d->flow == LeftToRight && !d->wrap))
|
&& ((d->flow == TopToBottom && d->wrap) || (d->flow == LeftToRight && !d->wrap))
|
||||||
&& d->vbar->minimum() == 0 && d->vbar->maximum() == 0) {
|
&& d->vbar->minimum() == 0 && d->vbar->maximum() == 0) {
|
||||||
QPoint pixelDelta(e->pixelDelta().y(), e->pixelDelta().x());
|
QPoint pixelDelta(e->pixelDelta().y(), e->pixelDelta().x());
|
||||||
QPoint angleDelta(e->angleDelta().y(), e->angleDelta().x());
|
QPoint angleDelta(e->angleDelta().y(), e->angleDelta().x());
|
||||||
QWheelEvent hwe(e->pos(), e->globalPos(), pixelDelta, angleDelta, e->delta(),
|
QWheelEvent hwe(e->position(), e->globalPosition(), pixelDelta, angleDelta,
|
||||||
Qt::Horizontal, e->buttons(), e->modifiers(), e->phase(), e->source(), e->inverted());
|
e->buttons(), e->modifiers(), e->phase(), e->inverted(), e->source());
|
||||||
if (e->spontaneous())
|
if (e->spontaneous())
|
||||||
qt_sendSpontaneousEvent(d->hbar, &hwe);
|
qt_sendSpontaneousEvent(d->hbar, &hwe);
|
||||||
else
|
else
|
||||||
|
@ -3240,13 +3240,18 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
|||||||
if (spontaneous && phase == Qt::ScrollBegin)
|
if (spontaneous && phase == Qt::ScrollBegin)
|
||||||
QApplicationPrivate::wheel_widget = nullptr;
|
QApplicationPrivate::wheel_widget = nullptr;
|
||||||
|
|
||||||
const QPoint &relpos = wheel->pos();
|
QPoint relpos = wheel->position().toPoint();
|
||||||
|
|
||||||
if (spontaneous && (phase == Qt::NoScrollPhase || phase == Qt::ScrollUpdate))
|
if (spontaneous && (phase == Qt::NoScrollPhase || phase == Qt::ScrollUpdate))
|
||||||
QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, relpos);
|
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(),
|
QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(),
|
||||||
wheel->modifiers(), phase, wheel->source(), wheel->inverted());
|
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());
|
we.setTimestamp(wheel->timestamp());
|
||||||
bool eventAccepted;
|
bool eventAccepted;
|
||||||
do {
|
do {
|
||||||
@ -3281,9 +3286,14 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
|||||||
// is set. Since it accepted the wheel event previously, we continue
|
// is set. Since it accepted the wheel event previously, we continue
|
||||||
// sending those events until we get a ScrollEnd, which signifies
|
// sending those events until we get a ScrollEnd, which signifies
|
||||||
// the end of the natural scrolling sequence.
|
// 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(),
|
QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(),
|
||||||
wheel->modifiers(), wheel->phase(), wheel->source());
|
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.setTimestamp(wheel->timestamp());
|
||||||
we.spont = true;
|
we.spont = true;
|
||||||
we.ignore();
|
we.ignore();
|
||||||
|
@ -828,14 +828,14 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QWidget *rootWidget = m_widget;
|
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
|
// 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.
|
// event to the root menu, so redirect it to the proper popup window.
|
||||||
QWidget *activePopupWidget = QApplication::activePopupWidget();
|
QWidget *activePopupWidget = QApplication::activePopupWidget();
|
||||||
if (activePopupWidget && activePopupWidget != m_widget) {
|
if (activePopupWidget && activePopupWidget != m_widget) {
|
||||||
rootWidget = activePopupWidget;
|
rootWidget = activePopupWidget;
|
||||||
pos = rootWidget->mapFromGlobal(event->globalPos());
|
pos = rootWidget->mapFromGlobal(event->globalPosition().toPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
// which child should have it?
|
// which child should have it?
|
||||||
@ -846,7 +846,12 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
|
|||||||
|
|
||||||
QPoint mapped = widget->mapFrom(rootWidget, pos);
|
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());
|
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());
|
translated.setTimestamp(event->timestamp());
|
||||||
QGuiApplication::forwardEvent(widget, &translated, event);
|
QGuiApplication::forwardEvent(widget, &translated, event);
|
||||||
}
|
}
|
||||||
|
@ -1324,7 +1324,7 @@ void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e)
|
|||||||
void QAbstractScrollArea::wheelEvent(QWheelEvent *e)
|
void QAbstractScrollArea::wheelEvent(QWheelEvent *e)
|
||||||
{
|
{
|
||||||
Q_D(QAbstractScrollArea);
|
Q_D(QAbstractScrollArea);
|
||||||
if (e->orientation() == Qt::Horizontal)
|
if (qAbs(e->angleDelta().x()) > qAbs(e->angleDelta().y()))
|
||||||
QCoreApplication::sendEvent(d->hbar, e);
|
QCoreApplication::sendEvent(d->hbar, e);
|
||||||
else
|
else
|
||||||
QCoreApplication::sendEvent(d->vbar, e);
|
QCoreApplication::sendEvent(d->vbar, e);
|
||||||
|
@ -764,10 +764,11 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
|
|||||||
{
|
{
|
||||||
Q_D(QAbstractSlider);
|
Q_D(QAbstractSlider);
|
||||||
e->ignore();
|
e->ignore();
|
||||||
int delta = e->delta();
|
bool vertical = bool(e->angleDelta().y());
|
||||||
|
int delta = vertical ? e->angleDelta().y() : e->angleDelta().x();
|
||||||
if (e->inverted())
|
if (e->inverted())
|
||||||
delta = -delta;
|
delta = -delta;
|
||||||
if (d->scrollByDelta(e->orientation(), e->modifiers(), delta))
|
if (d->scrollByDelta(vertical ? Qt::Vertical : Qt::Horizontal, e->modifiers(), delta))
|
||||||
e->accept();
|
e->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1418,7 +1418,7 @@ void QCalendarView::keyPressEvent(QKeyEvent *event)
|
|||||||
#if QT_CONFIG(wheelevent)
|
#if QT_CONFIG(wheelevent)
|
||||||
void QCalendarView::wheelEvent(QWheelEvent *event)
|
void QCalendarView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
const int numDegrees = event->delta() / 8;
|
const int numDegrees = event->angleDelta().y() / 8;
|
||||||
const int numSteps = numDegrees / 15;
|
const int numSteps = numDegrees / 15;
|
||||||
const QModelIndex index = currentIndex();
|
const QModelIndex index = currentIndex();
|
||||||
QDate currentDate = static_cast<QCalendarModel*>(model())->dateForCell(index.row(), index.column());
|
QDate currentDate = static_cast<QCalendarModel*>(model())->dateForCell(index.row(), index.column());
|
||||||
|
@ -3378,12 +3378,13 @@ void QComboBox::wheelEvent(QWheelEvent *e)
|
|||||||
!d->viewContainer()->isVisible()) {
|
!d->viewContainer()->isVisible()) {
|
||||||
const int rowCount = count();
|
const int rowCount = count();
|
||||||
int newIndex = currentIndex();
|
int newIndex = currentIndex();
|
||||||
|
int delta = e->angleDelta().y();
|
||||||
|
|
||||||
if (e->delta() > 0) {
|
if (delta > 0) {
|
||||||
newIndex--;
|
newIndex--;
|
||||||
while ((newIndex >= 0) && !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled))
|
while ((newIndex >= 0) && !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled))
|
||||||
newIndex--;
|
newIndex--;
|
||||||
} else if (e->delta() < 0) {
|
} else if (delta < 0) {
|
||||||
newIndex++;
|
newIndex++;
|
||||||
while (newIndex < rowCount && !(d->model->index(newIndex, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled))
|
while (newIndex < rowCount && !(d->model->index(newIndex, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled))
|
||||||
newIndex++;
|
newIndex++;
|
||||||
|
@ -2847,8 +2847,8 @@ void QMenu::paintEvent(QPaintEvent *e)
|
|||||||
void QMenu::wheelEvent(QWheelEvent *e)
|
void QMenu::wheelEvent(QWheelEvent *e)
|
||||||
{
|
{
|
||||||
Q_D(QMenu);
|
Q_D(QMenu);
|
||||||
if (d->scroll && rect().contains(e->pos()))
|
if (d->scroll && rect().contains(e->position().toPoint()))
|
||||||
d->scrollMenu(e->delta() > 0 ?
|
d->scrollMenu(e->angleDelta().y() > 0 ?
|
||||||
QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown);
|
QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -497,16 +497,14 @@ bool QScrollBar::event(QEvent *event)
|
|||||||
void QScrollBar::wheelEvent(QWheelEvent *event)
|
void QScrollBar::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
event->ignore();
|
event->ignore();
|
||||||
int delta = event->delta();
|
|
||||||
// scrollbar is a special case - in vertical mode it reaches minimum
|
// scrollbar is a special case - in vertical mode it reaches minimum
|
||||||
// value in the upper position, however QSlider's minimum value is on
|
// 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
|
// the bottom. So we need to invert the value, but since the scrollbar is
|
||||||
// inverted by default, we need to inverse the delta value for the
|
// inverted by default, we need to invert the delta value only for the
|
||||||
// horizontal orientation.
|
// horizontal orientation.
|
||||||
if (event->orientation() == Qt::Horizontal)
|
int delta = (orientation() == Qt::Horizontal ? -event->angleDelta().x() : event->angleDelta().y());
|
||||||
delta = -delta;
|
|
||||||
Q_D(QScrollBar);
|
Q_D(QScrollBar);
|
||||||
if (d->scrollByDelta(event->orientation(), event->modifiers(), delta))
|
if (d->scrollByDelta(orientation(), event->modifiers(), delta))
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
if (event->phase() == Qt::ScrollBegin)
|
if (event->phase() == Qt::ScrollBegin)
|
||||||
|
@ -2210,7 +2210,9 @@ void QTabBar::wheelEvent(QWheelEvent *event)
|
|||||||
{
|
{
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
Q_D(QTabBar);
|
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);
|
d->setCurrentNextEnabledIndex(offset);
|
||||||
QWidget::wheelEvent(event);
|
QWidget::wheelEvent(event);
|
||||||
#else
|
#else
|
||||||
|
@ -2219,7 +2219,7 @@ void tst_QGraphicsView::wheelEvent()
|
|||||||
{
|
{
|
||||||
QWheelEvent event(view.mapFromScene(widget->boundingRect().center()),
|
QWheelEvent event(view.mapFromScene(widget->boundingRect().center()),
|
||||||
view.mapToGlobal(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);
|
QApplication::sendEvent(view.viewport(), &event);
|
||||||
QCOMPARE(scene.orientation, Qt::Horizontal);
|
QCOMPARE(scene.orientation, Qt::Horizontal);
|
||||||
}
|
}
|
||||||
@ -2228,7 +2228,7 @@ void tst_QGraphicsView::wheelEvent()
|
|||||||
{
|
{
|
||||||
QWheelEvent event(view.mapFromScene(widget->boundingRect().center()),
|
QWheelEvent event(view.mapFromScene(widget->boundingRect().center()),
|
||||||
view.mapToGlobal(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);
|
QApplication::sendEvent(view.viewport(), &event);
|
||||||
QCOMPARE(scene.orientation, Qt::Vertical);
|
QCOMPARE(scene.orientation, Qt::Vertical);
|
||||||
}
|
}
|
||||||
|
@ -2516,9 +2516,9 @@ void tst_QListView::horizontalScrollingByVerticalWheelEvents()
|
|||||||
QPoint globalPos = lv.geometry().center();
|
QPoint globalPos = lv.geometry().center();
|
||||||
QPoint pos = lv.viewport()->geometry().center();
|
QPoint pos = lv.viewport()->geometry().center();
|
||||||
|
|
||||||
QWheelEvent wheelDownEvent(pos, globalPos, QPoint(0, 0), QPoint(0, -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), 120, Qt::Vertical, 0, 0);
|
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), -120, Qt::Vertical, 0, 0);
|
QWheelEvent wheelLeftDownEvent(pos, globalPos, QPoint(0, 0), QPoint(120, -120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false);
|
||||||
|
|
||||||
int hValue = lv.horizontalScrollBar()->value();
|
int hValue = lv.horizontalScrollBar()->value();
|
||||||
QApplication::sendEvent(lv.viewport(), &wheelDownEvent);
|
QApplication::sendEvent(lv.viewport(), &wheelDownEvent);
|
||||||
|
@ -4074,8 +4074,10 @@ void tst_QTableView::mouseWheel()
|
|||||||
view.verticalScrollBar()->setValue(10);
|
view.verticalScrollBar()->setValue(10);
|
||||||
|
|
||||||
QPoint pos = view.viewport()->geometry().center();
|
QPoint pos = view.viewport()->geometry().center();
|
||||||
QWheelEvent verticalEvent(pos, delta, 0, 0, Qt::Vertical);
|
QWheelEvent verticalEvent(pos, view.mapToGlobal(pos), QPoint(), QPoint(0, delta),
|
||||||
QWheelEvent horizontalEvent(pos, delta, 0, 0, Qt::Horizontal);
|
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);
|
QApplication::sendEvent(view.viewport(), &horizontalEvent);
|
||||||
QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 15);
|
QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 15);
|
||||||
QApplication::sendEvent(view.viewport(), &verticalEvent);
|
QApplication::sendEvent(view.viewport(), &verticalEvent);
|
||||||
@ -4350,7 +4352,9 @@ void tst_QTableView::taskQTBUG_5237_wheelEventOnHeader()
|
|||||||
int sbValueBefore = view.verticalScrollBar()->value();
|
int sbValueBefore = view.verticalScrollBar()->value();
|
||||||
QHeaderView *header = view.verticalHeader();
|
QHeaderView *header = view.verticalHeader();
|
||||||
QTest::mouseMove(header);
|
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);
|
QApplication::sendEvent(header->viewport(), &wheelEvent);
|
||||||
int sbValueAfter = view.verticalScrollBar()->value();
|
int sbValueAfter = view.verticalScrollBar()->value();
|
||||||
QVERIFY(sbValueBefore != sbValueAfter);
|
QVERIFY(sbValueBefore != sbValueAfter);
|
||||||
|
@ -1662,8 +1662,12 @@ void tst_QAbstractSlider::wheelEvent()
|
|||||||
slider->setOrientation(sliderOrientation);
|
slider->setOrientation(sliderOrientation);
|
||||||
|
|
||||||
Qt::KeyboardModifier k = withModifiers ? Qt::ControlModifier : Qt::NoModifier;
|
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));
|
QVERIFY(applicationInstance->sendEvent(slider,&event));
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QEXPECT_FAIL("Normal data page", "QTBUG-23679", Continue);
|
QEXPECT_FAIL("Normal data page", "QTBUG-23679", Continue);
|
||||||
@ -1674,8 +1678,8 @@ void tst_QAbstractSlider::wheelEvent()
|
|||||||
|
|
||||||
slider->setSliderPosition(initialSliderPosition);
|
slider->setSliderPosition(initialSliderPosition);
|
||||||
k = withModifiers ? Qt::ShiftModifier : Qt::NoModifier;
|
k = withModifiers ? Qt::ShiftModifier : Qt::NoModifier;
|
||||||
event = QWheelEvent(slider->rect().bottomRight() + distanceFromBottomRight, WHEEL_DELTA * deltaMultiple,
|
event = QWheelEvent(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), angleDelta,
|
||||||
Qt::NoButton, k, wheelOrientation);
|
Qt::NoButton, k, Qt::NoScrollPhase, false);
|
||||||
QSignalSpy spy1(slider, SIGNAL(actionTriggered(int)));
|
QSignalSpy spy1(slider, SIGNAL(actionTriggered(int)));
|
||||||
QSignalSpy spy2(slider, SIGNAL(valueChanged(int)));
|
QSignalSpy spy2(slider, SIGNAL(valueChanged(int)));
|
||||||
QVERIFY(applicationInstance->sendEvent(slider,&event));
|
QVERIFY(applicationInstance->sendEvent(slider,&event));
|
||||||
@ -1715,16 +1719,16 @@ void tst_QAbstractSlider::fineGrainedWheelEvent()
|
|||||||
slider->setSliderPosition(0);
|
slider->setSliderPosition(0);
|
||||||
|
|
||||||
const int singleStepDelta = invertedControls ? (-WHEEL_DELTA / 3) : (WHEEL_DELTA / 3);
|
const int singleStepDelta = invertedControls ? (-WHEEL_DELTA / 3) : (WHEEL_DELTA / 3);
|
||||||
|
const QPoint wheelPoint = slider->rect().bottomRight();
|
||||||
QWheelEvent eventDown(slider->rect().bottomRight(), singleStepDelta / 2,
|
QWheelEvent eventDown(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), QPoint(0, singleStepDelta / 2),
|
||||||
Qt::NoButton, Qt::NoModifier, Qt::Vertical);
|
Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false);
|
||||||
QVERIFY(applicationInstance->sendEvent(slider,&eventDown));
|
QVERIFY(applicationInstance->sendEvent(slider,&eventDown));
|
||||||
QCOMPARE(slider->sliderPosition(), 0);
|
QCOMPARE(slider->sliderPosition(), 0);
|
||||||
QVERIFY(applicationInstance->sendEvent(slider,&eventDown));
|
QVERIFY(applicationInstance->sendEvent(slider,&eventDown));
|
||||||
QCOMPARE(slider->sliderPosition(), 1);
|
QCOMPARE(slider->sliderPosition(), 1);
|
||||||
|
|
||||||
QWheelEvent eventUp(slider->rect().bottomRight(), -singleStepDelta / 2,
|
QWheelEvent eventUp(wheelPoint, slider->mapToGlobal(wheelPoint), QPoint(), QPoint(0, -singleStepDelta / 2),
|
||||||
Qt::NoButton, Qt::NoModifier, Qt::Vertical);
|
Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false);
|
||||||
QVERIFY(applicationInstance->sendEvent(slider,&eventUp));
|
QVERIFY(applicationInstance->sendEvent(slider,&eventUp));
|
||||||
QCOMPARE(slider->sliderPosition(), 1);
|
QCOMPARE(slider->sliderPosition(), 1);
|
||||||
QVERIFY(applicationInstance->sendEvent(slider,&eventUp));
|
QVERIFY(applicationInstance->sendEvent(slider,&eventUp));
|
||||||
|
@ -2102,7 +2102,9 @@ void tst_QComboBox::mouseWheel()
|
|||||||
box.setEditable(i==0?false:true);
|
box.setEditable(i==0?false:true);
|
||||||
box.setCurrentIndex(startIndex);
|
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));
|
QVERIFY(applicationInstance->sendEvent(&box,&event));
|
||||||
|
|
||||||
QCOMPARE(box.currentIndex(), expectedIndex);
|
QCOMPARE(box.currentIndex(), expectedIndex);
|
||||||
@ -2131,7 +2133,9 @@ void tst_QComboBox::popupWheelHandling()
|
|||||||
comboBox->showPopup();
|
comboBox->showPopup();
|
||||||
QTRY_VERIFY(comboBox->view() && comboBox->view()->isVisible());
|
QTRY_VERIFY(comboBox->view() && comboBox->view()->isVisible());
|
||||||
const QPoint popupPos = comboBox->view()->pos();
|
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));
|
QVERIFY(QCoreApplication::sendEvent(scrollArea.windowHandle(), &event));
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
QVERIFY(comboBox->view()->isVisible());
|
QVERIFY(comboBox->view()->isVisible());
|
||||||
|
@ -3141,7 +3141,6 @@ void tst_QDateTimeEdit::wheelEvent_data()
|
|||||||
{
|
{
|
||||||
#if QT_CONFIG(wheelevent)
|
#if QT_CONFIG(wheelevent)
|
||||||
QTest::addColumn<QPoint>("angleDelta");
|
QTest::addColumn<QPoint>("angleDelta");
|
||||||
QTest::addColumn<int>("qt4Delta");
|
|
||||||
QTest::addColumn<int>("stepModifier");
|
QTest::addColumn<int>("stepModifier");
|
||||||
QTest::addColumn<Qt::KeyboardModifiers>("modifiers");
|
QTest::addColumn<Qt::KeyboardModifiers>("modifiers");
|
||||||
QTest::addColumn<Qt::MouseEventSource>("source");
|
QTest::addColumn<Qt::MouseEventSource>("source");
|
||||||
@ -3255,7 +3254,6 @@ void tst_QDateTimeEdit::wheelEvent_data()
|
|||||||
modifierName.latin1(),
|
modifierName.latin1(),
|
||||||
sourceName.latin1())
|
sourceName.latin1())
|
||||||
<< angleDelta
|
<< angleDelta
|
||||||
<< units
|
|
||||||
<< static_cast<int>(stepModifier)
|
<< static_cast<int>(stepModifier)
|
||||||
<< modifiers
|
<< modifiers
|
||||||
<< source
|
<< source
|
||||||
@ -3277,7 +3275,6 @@ void tst_QDateTimeEdit::wheelEvent()
|
|||||||
{
|
{
|
||||||
#if QT_CONFIG(wheelevent)
|
#if QT_CONFIG(wheelevent)
|
||||||
QFETCH(QPoint, angleDelta);
|
QFETCH(QPoint, angleDelta);
|
||||||
QFETCH(int, qt4Delta);
|
|
||||||
QFETCH(int, stepModifier);
|
QFETCH(int, stepModifier);
|
||||||
QFETCH(Qt::KeyboardModifiers, modifiers);
|
QFETCH(Qt::KeyboardModifiers, modifiers);
|
||||||
QFETCH(Qt::MouseEventSource, source);
|
QFETCH(Qt::MouseEventSource, source);
|
||||||
@ -3294,9 +3291,8 @@ void tst_QDateTimeEdit::wheelEvent()
|
|||||||
style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier);
|
style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier);
|
||||||
edit.setStyle(style.data());
|
edit.setStyle(style.data());
|
||||||
|
|
||||||
QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, qt4Delta,
|
QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta,
|
||||||
Qt::Vertical, Qt::NoButton, modifiers, Qt::NoScrollPhase,
|
Qt::NoButton, modifiers, Qt::NoScrollPhase, false, source);
|
||||||
source);
|
|
||||||
|
|
||||||
QCOMPARE(edit.date(), startDate);
|
QCOMPARE(edit.date(), startDate);
|
||||||
for (QDate expected : expectedDates) {
|
for (QDate expected : expectedDates) {
|
||||||
|
@ -1377,7 +1377,6 @@ void tst_QDoubleSpinBox::wheelEvents_data()
|
|||||||
{
|
{
|
||||||
#if QT_CONFIG(wheelevent)
|
#if QT_CONFIG(wheelevent)
|
||||||
QTest::addColumn<QPoint>("angleDelta");
|
QTest::addColumn<QPoint>("angleDelta");
|
||||||
QTest::addColumn<int>("qt4Delta");
|
|
||||||
QTest::addColumn<int>("stepModifier");
|
QTest::addColumn<int>("stepModifier");
|
||||||
QTest::addColumn<Qt::KeyboardModifiers>("modifier");
|
QTest::addColumn<Qt::KeyboardModifiers>("modifier");
|
||||||
QTest::addColumn<Qt::MouseEventSource>("source");
|
QTest::addColumn<Qt::MouseEventSource>("source");
|
||||||
@ -1476,7 +1475,6 @@ void tst_QDoubleSpinBox::wheelEvents_data()
|
|||||||
modifierName.latin1(),
|
modifierName.latin1(),
|
||||||
sourceName.latin1())
|
sourceName.latin1())
|
||||||
<< angleDelta
|
<< angleDelta
|
||||||
<< units
|
|
||||||
<< static_cast<int>(stepModifier)
|
<< static_cast<int>(stepModifier)
|
||||||
<< modifiers
|
<< modifiers
|
||||||
<< source
|
<< source
|
||||||
@ -1496,7 +1494,6 @@ void tst_QDoubleSpinBox::wheelEvents()
|
|||||||
{
|
{
|
||||||
#if QT_CONFIG(wheelevent)
|
#if QT_CONFIG(wheelevent)
|
||||||
QFETCH(QPoint, angleDelta);
|
QFETCH(QPoint, angleDelta);
|
||||||
QFETCH(int, qt4Delta);
|
|
||||||
QFETCH(int, stepModifier);
|
QFETCH(int, stepModifier);
|
||||||
QFETCH(Qt::KeyboardModifiers, modifier);
|
QFETCH(Qt::KeyboardModifiers, modifier);
|
||||||
QFETCH(Qt::MouseEventSource, source);
|
QFETCH(Qt::MouseEventSource, source);
|
||||||
@ -1512,9 +1509,8 @@ void tst_QDoubleSpinBox::wheelEvents()
|
|||||||
style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier);
|
style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier);
|
||||||
spinBox.setStyle(style.data());
|
spinBox.setStyle(style.data());
|
||||||
|
|
||||||
QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, qt4Delta,
|
QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta,
|
||||||
Qt::Vertical, Qt::NoButton, modifier, Qt::NoScrollPhase,
|
Qt::NoButton, modifier, Qt::NoScrollPhase, source);
|
||||||
source);
|
|
||||||
for (int expected : expectedValues) {
|
for (int expected : expectedValues) {
|
||||||
qApp->sendEvent(&spinBox, &event);
|
qApp->sendEvent(&spinBox, &event);
|
||||||
QCOMPARE(spinBox.value(), expected);
|
QCOMPARE(spinBox.value(), expected);
|
||||||
|
@ -151,8 +151,11 @@ void tst_QScrollBar::QTBUG_27308()
|
|||||||
|
|
||||||
testWidget.setValue(testWidget.minimum());
|
testWidget.setValue(testWidget.minimum());
|
||||||
testWidget.setEnabled(false);
|
testWidget.setEnabled(false);
|
||||||
QWheelEvent event(testWidget.rect().center(),
|
const QPoint wheelPoint = testWidget.rect().center();
|
||||||
-WHEEL_DELTA, Qt::NoButton, Qt::NoModifier, testWidget.orientation());
|
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);
|
qApp->sendEvent(&testWidget, &event);
|
||||||
QCOMPARE(testWidget.value(), testWidget.minimum());
|
QCOMPARE(testWidget.value(), testWidget.minimum());
|
||||||
}
|
}
|
||||||
|
@ -1331,7 +1331,6 @@ void tst_QSpinBox::wheelEvents_data()
|
|||||||
{
|
{
|
||||||
#if QT_CONFIG(wheelevent)
|
#if QT_CONFIG(wheelevent)
|
||||||
QTest::addColumn<QPoint>("angleDelta");
|
QTest::addColumn<QPoint>("angleDelta");
|
||||||
QTest::addColumn<int>("qt4Delta");
|
|
||||||
QTest::addColumn<int>("stepModifier");
|
QTest::addColumn<int>("stepModifier");
|
||||||
QTest::addColumn<Qt::KeyboardModifiers>("modifier");
|
QTest::addColumn<Qt::KeyboardModifiers>("modifier");
|
||||||
QTest::addColumn<Qt::MouseEventSource>("source");
|
QTest::addColumn<Qt::MouseEventSource>("source");
|
||||||
@ -1430,7 +1429,6 @@ void tst_QSpinBox::wheelEvents_data()
|
|||||||
modifierName.latin1(),
|
modifierName.latin1(),
|
||||||
sourceName.latin1())
|
sourceName.latin1())
|
||||||
<< angleDelta
|
<< angleDelta
|
||||||
<< units
|
|
||||||
<< static_cast<int>(stepModifier)
|
<< static_cast<int>(stepModifier)
|
||||||
<< modifiers
|
<< modifiers
|
||||||
<< source
|
<< source
|
||||||
@ -1450,7 +1448,6 @@ void tst_QSpinBox::wheelEvents()
|
|||||||
{
|
{
|
||||||
#if QT_CONFIG(wheelevent)
|
#if QT_CONFIG(wheelevent)
|
||||||
QFETCH(QPoint, angleDelta);
|
QFETCH(QPoint, angleDelta);
|
||||||
QFETCH(int, qt4Delta);
|
|
||||||
QFETCH(int, stepModifier);
|
QFETCH(int, stepModifier);
|
||||||
QFETCH(Qt::KeyboardModifiers, modifier);
|
QFETCH(Qt::KeyboardModifiers, modifier);
|
||||||
QFETCH(Qt::MouseEventSource, source);
|
QFETCH(Qt::MouseEventSource, source);
|
||||||
@ -1466,9 +1463,8 @@ void tst_QSpinBox::wheelEvents()
|
|||||||
style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier);
|
style->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier);
|
||||||
spinBox.setStyle(style.data());
|
spinBox.setStyle(style.data());
|
||||||
|
|
||||||
QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta, qt4Delta,
|
QWheelEvent event(QPointF(), QPointF(), QPoint(), angleDelta,
|
||||||
Qt::Vertical, Qt::NoButton, modifier, Qt::NoScrollPhase,
|
Qt::NoButton, modifier, Qt::NoScrollPhase, source);
|
||||||
source);
|
|
||||||
for (int expected : expectedValues) {
|
for (int expected : expectedValues) {
|
||||||
qApp->sendEvent(&spinBox, &event);
|
qApp->sendEvent(&spinBox, &event);
|
||||||
QCOMPARE(spinBox.value(), expected);
|
QCOMPARE(spinBox.value(), expected);
|
||||||
|
@ -2669,12 +2669,14 @@ void tst_QTextEdit::wheelEvent()
|
|||||||
ed.setReadOnly(true);
|
ed.setReadOnly(true);
|
||||||
|
|
||||||
float defaultFontSize = ed.font().pointSizeF();
|
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);
|
ed.wheelEvent(&wheelUp);
|
||||||
|
|
||||||
QCOMPARE(defaultFontSize + 1, ed.font().pointSizeF());
|
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);
|
ed.wheelEvent(&wheelHalfDown);
|
||||||
|
|
||||||
QCOMPARE(defaultFontSize + 0.5, ed.font().pointSizeF());
|
QCOMPARE(defaultFontSize + 0.5, ed.font().pointSizeF());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user