Prepare to harmonize pointer event accessor names
...by deprecating everything that doesn't conform to the naming scheme,
and providing replacements. Continues what was started with QWheelEvent
in 7d29807296
. However QMouseEvent::pos()
is left un-deprecated because it's so widely used.
Also quit returning QPointF by const-ref from accessors. It's plenty
small enough to return by value; we were never consistent about it anyway;
and it's good to avoid some problems with returning a reference to a
temporary in case the value is calculated in the accessor.
[ChangeLog][QtGui][QPointerEvent] Mouse, touch and tablet events now
have a standard set of QPointF accessors: position(), scenePosition()
and globalPosition(). Existing accessors that return integer QPoints,
and those with non-standard names, have been deprecated. You can use the
clazy qevent-accessors check to update your code accordingly.
Task-number: QTBUG-20885
Task-number: QTBUG-84775
Change-Id: I8e6f587da76d6d0bca6e965ce8ebc7e67b868011
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
f19522a1b3
commit
24e52c10de
@ -74,16 +74,16 @@ QT_BEGIN_NAMESPACE
|
|||||||
/*!
|
/*!
|
||||||
Constructs an enter event object.
|
Constructs an enter event object.
|
||||||
|
|
||||||
The points \a localPos, \a windowPos and \a screenPos specify the
|
The points \a localPos, \a scenePos and \a globalPos specify the
|
||||||
mouse cursor's position relative to the receiving widget or item,
|
mouse cursor's position relative to the receiving widget or item,
|
||||||
window, and screen, respectively.
|
window, and screen or desktop, respectively.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QEnterEvent::QEnterEvent(const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos)
|
QEnterEvent::QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos)
|
||||||
: QEvent(QEvent::Enter)
|
: QEvent(QEvent::Enter)
|
||||||
, l(localPos)
|
, l(localPos)
|
||||||
, w(windowPos)
|
, s(scenePos)
|
||||||
, s(screenPos)
|
, g(globalPos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,10 +226,10 @@ QInputEvent::~QInputEvent()
|
|||||||
\l{QInputEvent::modifiers()}{modifiers()} function, inherited from
|
\l{QInputEvent::modifiers()}{modifiers()} function, inherited from
|
||||||
QInputEvent.
|
QInputEvent.
|
||||||
|
|
||||||
The functions pos(), x(), and y() give the cursor position
|
The position() function gives the cursor position
|
||||||
relative to the widget that receives the mouse event. If you
|
relative to the widget or item that receives the mouse event.
|
||||||
move the widget as a result of the mouse event, use the global
|
If you move the widget as a result of the mouse event, use the
|
||||||
position returned by globalPos() to avoid a shaking motion.
|
global position returned by globalPosition() to avoid a shaking motion.
|
||||||
|
|
||||||
The QWidget::setEnabled() function can be used to enable or
|
The QWidget::setEnabled() function can be used to enable or
|
||||||
disable mouse and keyboard events for a widget.
|
disable mouse and keyboard events for a widget.
|
||||||
@ -259,7 +259,7 @@ QInputEvent::~QInputEvent()
|
|||||||
The mouse and keyboard states at the time of the event are specified by
|
The mouse and keyboard states at the time of the event are specified by
|
||||||
\a buttons and \a modifiers.
|
\a buttons and \a modifiers.
|
||||||
|
|
||||||
The screenPos() is initialized to QCursor::pos(), which may not
|
The globalPosition() is initialized to QCursor::pos(), which may not
|
||||||
be appropriate. Use the other constructor to specify the global
|
be appropriate. Use the other constructor to specify the global
|
||||||
position explicitly.
|
position explicitly.
|
||||||
*/
|
*/
|
||||||
@ -268,7 +268,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but
|
|||||||
: QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0)
|
: QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0)
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
s = QCursor::pos();
|
g = QCursor::pos();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but
|
|||||||
|
|
||||||
The \a localPos is the mouse cursor's position relative to the
|
The \a localPos is the mouse cursor's position relative to the
|
||||||
receiving widget or item. The cursor's position in screen coordinates is
|
receiving widget or item. The cursor's position in screen coordinates is
|
||||||
specified by \a screenPos. The window position is set to the same value
|
specified by \a globalPos. The window position is set to the same value
|
||||||
as \a localPos. The \a button that caused the event is
|
as \a localPos. The \a button that caused the event is
|
||||||
given as a value from the \l Qt::MouseButton enum. If the event \a
|
given as a value from the \l Qt::MouseButton enum. If the event \a
|
||||||
type is \l MouseMove, the appropriate button for this event is
|
type is \l MouseMove, the appropriate button for this event is
|
||||||
@ -291,10 +291,10 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but
|
|||||||
modifiers.
|
modifiers.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos,
|
QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &globalPos,
|
||||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||||
Qt::KeyboardModifiers modifiers)
|
Qt::KeyboardModifiers modifiers)
|
||||||
: QMouseEvent(type, localPos, localPos, screenPos, button, buttons, modifiers)
|
: QMouseEvent(type, localPos, localPos, globalPos, button, buttons, modifiers)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -304,9 +304,9 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &scre
|
|||||||
QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
|
QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
|
||||||
or QEvent::MouseMove.
|
or QEvent::MouseMove.
|
||||||
|
|
||||||
The points \a localPos, \a windowPos and \a screenPos specify the
|
The points \a localPos, \a scenePos and \a globalPos specify the
|
||||||
mouse cursor's position relative to the receiving widget or item,
|
mouse cursor's position relative to the receiving widget or item,
|
||||||
window, and screen, respectively.
|
window, and screen or desktop, respectively.
|
||||||
|
|
||||||
The \a button that caused the event is
|
The \a button that caused the event is
|
||||||
given as a value from the \l Qt::MouseButton enum. If the event \a
|
given as a value from the \l Qt::MouseButton enum. If the event \a
|
||||||
@ -316,10 +316,10 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &scre
|
|||||||
modifiers.
|
modifiers.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
|
QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
|
||||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||||
Qt::KeyboardModifiers modifiers)
|
Qt::KeyboardModifiers modifiers)
|
||||||
: QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
|
: QInputEvent(type, modifiers), l(localPos), w(scenePos), g(globalPos), b(button), mouseState(buttons), caps(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -331,9 +331,9 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &wind
|
|||||||
QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
|
QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
|
||||||
or QEvent::MouseMove.
|
or QEvent::MouseMove.
|
||||||
|
|
||||||
The points \a localPos, \a windowPos and \a screenPos specify the
|
The points \a localPos, \a scenePos and \a globalPos specify the
|
||||||
mouse cursor's position relative to the receiving widget or item,
|
mouse cursor's position relative to the receiving widget or item,
|
||||||
window, and screen, respectively.
|
window, and screen or desktop, respectively.
|
||||||
|
|
||||||
The \a button that caused the event is given as a value from the
|
The \a button that caused the event is given as a value from the
|
||||||
\l Qt::MouseButton enum. If the event \a type is \l MouseMove,
|
\l Qt::MouseButton enum. If the event \a type is \l MouseMove,
|
||||||
@ -344,10 +344,10 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &wind
|
|||||||
The source of the event is specified by \a source.
|
The source of the event is specified by \a source.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
|
QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
|
||||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||||
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
|
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
|
||||||
: QMouseEvent(type, localPos, windowPos, screenPos, button, buttons, modifiers)
|
: QMouseEvent(type, localPos, scenePos, globalPos, button, buttons, modifiers)
|
||||||
{
|
{
|
||||||
QGuiApplicationPrivate::setMouseEventSource(this, source);
|
QGuiApplicationPrivate::setMouseEventSource(this, source);
|
||||||
}
|
}
|
||||||
@ -852,7 +852,7 @@ QWheelEvent::~QWheelEvent()
|
|||||||
\since 5.14
|
\since 5.14
|
||||||
|
|
||||||
Returns the position of the mouse cursor relative to the widget
|
Returns the position of the mouse cursor relative to the widget
|
||||||
that received the event.
|
or item that received the event.
|
||||||
|
|
||||||
If you move your widgets around in response to mouse events,
|
If you move your widgets around in response to mouse events,
|
||||||
use globalPosition() instead of this function.
|
use globalPosition() instead of this function.
|
||||||
@ -2472,17 +2472,17 @@ Qt::MouseButtons QTabletEvent::buttons() const
|
|||||||
/*!
|
/*!
|
||||||
Constructs a native gesture event of type \a type originating from \a device.
|
Constructs a native gesture event of type \a type originating from \a device.
|
||||||
|
|
||||||
The points \a localPos, \a windowPos and \a screenPos specify the
|
The points \a localPos, \a scenePos and \a globalPos specify the
|
||||||
gesture position relative to the receiving widget or item,
|
gesture position relative to the receiving widget or item,
|
||||||
window, and screen, respectively.
|
window, and screen or desktop, respectively.
|
||||||
|
|
||||||
\a realValue is the \macos event parameter, \a sequenceId and \a intValue are the Windows event parameters.
|
\a realValue is the \macos event parameter, \a sequenceId and \a intValue are the Windows event parameters.
|
||||||
\since 5.10
|
\since 5.10
|
||||||
*/
|
*/
|
||||||
QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *device, const QPointF &localPos, const QPointF &windowPos,
|
QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *device, const QPointF &localPos, const QPointF &scenePos,
|
||||||
const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue)
|
const QPointF &globalPos, qreal realValue, ulong sequenceId, quint64 intValue)
|
||||||
: QInputEvent(QEvent::NativeGesture), mGestureType(type),
|
: QInputEvent(QEvent::NativeGesture), mGestureType(type),
|
||||||
mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue),
|
mLocalPos(localPos), mScenePos(scenePos), mGlobalPos(globalPos), mRealValue(realValue),
|
||||||
mSequenceId(sequenceId), mIntValue(intValue), mDevice(device)
|
mSequenceId(sequenceId), mIntValue(intValue), mDevice(device)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -4237,42 +4237,63 @@ Qt::TouchPointState QTouchEvent::TouchPoint::state() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\fn QPointF QTouchEvent::pos() const
|
||||||
|
\deprecated in Qt 6.0. Use position() instead.
|
||||||
|
|
||||||
Returns the position of this touch point, relative to the widget
|
Returns the position of this touch point, relative to the widget
|
||||||
or QGraphicsItem that received the event.
|
or item that received the event.
|
||||||
|
|
||||||
\sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
|
\sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
|
||||||
*/
|
*/
|
||||||
QPointF QTouchEvent::TouchPoint::pos() const
|
|
||||||
|
/*!
|
||||||
|
Returns the position of this touch point, relative to the widget
|
||||||
|
or item that received the event.
|
||||||
|
|
||||||
|
\sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
|
||||||
|
*/
|
||||||
|
QPointF QTouchEvent::TouchPoint::position() const
|
||||||
{
|
{
|
||||||
return d->pos;
|
return d->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the scene position of this touch point.
|
\fn QPointF QTouchEvent::scenePos() const
|
||||||
|
\deprecated in Qt 6.0. Use scenePosition() instead.
|
||||||
The scene position is the position in QGraphicsScene coordinates
|
|
||||||
if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
|
|
||||||
reimplementation, and identical to the screen position for
|
|
||||||
widgets.
|
|
||||||
|
|
||||||
\sa startScenePos(), lastScenePos(), pos()
|
|
||||||
*/
|
*/
|
||||||
QPointF QTouchEvent::TouchPoint::scenePos() const
|
|
||||||
|
/*!
|
||||||
|
Returns the position of this touch point relative to the window or scene.
|
||||||
|
|
||||||
|
The scene position is the position relative to QQuickWindow if handled in QQuickItem::event(),
|
||||||
|
in QGraphicsScene coordinates if handled by an override of QGraphicsItem::touchEvent(),
|
||||||
|
or the window position in widget applications.
|
||||||
|
|
||||||
|
\sa scenePressPosition(), position(), globalPosition()
|
||||||
|
*/
|
||||||
|
QPointF QTouchEvent::TouchPoint::scenePosition() const
|
||||||
{
|
{
|
||||||
return d->scenePos;
|
return d->scenePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the screen position of this touch point.
|
\fn QPointF QTouchEvent::screenPos() const
|
||||||
|
\deprecated in Qt 6.0. Use globalPosition() instead.
|
||||||
\sa startScreenPos(), lastScreenPos(), pos()
|
|
||||||
*/
|
*/
|
||||||
QPointF QTouchEvent::TouchPoint::screenPos() const
|
|
||||||
|
/*!
|
||||||
|
Returns the position of this touch point on the screen or virtual desktop.
|
||||||
|
|
||||||
|
\sa globalPressPosition(), position(), scenePosition()
|
||||||
|
*/
|
||||||
|
QPointF QTouchEvent::TouchPoint::globalPosition() const
|
||||||
{
|
{
|
||||||
return d->screenPos;
|
return d->screenPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\deprecated in Qt 6.0. Use globalPosition() instead.
|
||||||
|
|
||||||
Returns the normalized position of this touch point.
|
Returns the normalized position of this touch point.
|
||||||
|
|
||||||
The coordinates are normalized to the size of the touch device,
|
The coordinates are normalized to the size of the touch device,
|
||||||
@ -4286,43 +4307,58 @@ QPointF QTouchEvent::TouchPoint::normalizedPos() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the starting position of this touch point, relative to the
|
\fn QPointF QTouchEvent::startPos() const
|
||||||
widget or QGraphicsItem that received the event.
|
\deprecated in Qt 6.0. Use pressPosition() instead.
|
||||||
|
|
||||||
\sa pos(), lastPos()
|
|
||||||
*/
|
*/
|
||||||
QPointF QTouchEvent::TouchPoint::startPos() const
|
|
||||||
|
/*!
|
||||||
|
Returns the position at which this touch point was pressed, relative to the
|
||||||
|
widget or item that received the event.
|
||||||
|
|
||||||
|
\sa position()
|
||||||
|
*/
|
||||||
|
QPointF QTouchEvent::TouchPoint::pressPosition() const
|
||||||
{
|
{
|
||||||
return d->startPos;
|
return d->startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the starting scene position of this touch point.
|
\fn QPointF QTouchEvent::sceneStartPos() const
|
||||||
|
\deprecated in Qt 6.0. Use scenePressPosition() instead.
|
||||||
The scene position is the position in QGraphicsScene coordinates
|
|
||||||
if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
|
|
||||||
reimplementation, and identical to the screen position for
|
|
||||||
widgets.
|
|
||||||
|
|
||||||
\sa scenePos(), lastScenePos()
|
|
||||||
*/
|
*/
|
||||||
QPointF QTouchEvent::TouchPoint::startScenePos() const
|
|
||||||
|
/*!
|
||||||
|
Returns the scene position at which this touch point was pressed.
|
||||||
|
|
||||||
|
The scene position is the position relative to QQuickWindow if handled in QQuickItem::event(),
|
||||||
|
in QGraphicsScene coordinates if handled by an override of QGraphicsItem::touchEvent(),
|
||||||
|
or the window position in widget applications.
|
||||||
|
|
||||||
|
\sa scenePosition(), pressPosition(), globalPressPosition()
|
||||||
|
*/
|
||||||
|
QPointF QTouchEvent::TouchPoint::scenePressPosition() const
|
||||||
{
|
{
|
||||||
return d->startScenePos;
|
return d->startScenePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QPointF QTouchEvent::startScreenPos() const
|
||||||
|
\deprecated in Qt 6.0. Use globalPressPosition() instead.
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the starting screen position of this touch point.
|
Returns the starting screen position of this touch point.
|
||||||
|
|
||||||
\sa screenPos(), lastScreenPos()
|
\sa globalPosition(), pressPosition(), scenePressPosition()
|
||||||
*/
|
*/
|
||||||
QPointF QTouchEvent::TouchPoint::startScreenPos() const
|
QPointF QTouchEvent::TouchPoint::globalPressPosition() const
|
||||||
{
|
{
|
||||||
return d->startScreenPos;
|
return d->startScreenPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the normalized starting position of this touch point.
|
\deprecated in Qt 6.0. Use globalPressPosition() instead.
|
||||||
|
Returns the normalized press position of this touch point.
|
||||||
|
|
||||||
The coordinates are normalized to the size of the touch device,
|
The coordinates are normalized to the size of the touch device,
|
||||||
i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
|
i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
|
||||||
|
@ -84,23 +84,38 @@ protected:
|
|||||||
class Q_GUI_EXPORT QEnterEvent : public QEvent
|
class Q_GUI_EXPORT QEnterEvent : public QEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QEnterEvent(const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos);
|
QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos);
|
||||||
~QEnterEvent();
|
~QEnterEvent();
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||||
inline QPoint pos() const { return l.toPoint(); }
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
inline QPoint globalPos() const { return s.toPoint(); }
|
inline QPoint pos() const { return position().toPoint(); }
|
||||||
inline int x() const { return qRound(l.x()); }
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
inline int y() const { return qRound(l.y()); }
|
inline QPoint globalPos() const { return globalPosition().toPoint(); }
|
||||||
inline int globalX() const { return qRound(s.x()); }
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
inline int globalY() const { return qRound(s.y()); }
|
inline int x() const { return qRound(position().x()); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
|
inline int y() const { return qRound(position().y()); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
|
inline int globalX() const { return qRound(globalPosition().x()); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
|
inline int globalY() const { return qRound(globalPosition().y()); }
|
||||||
#endif
|
#endif
|
||||||
const QPointF &localPos() const { return l; }
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
const QPointF &windowPos() const { return w; }
|
QPointF localPos() const { return position(); }
|
||||||
const QPointF &screenPos() const { return s; }
|
QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()")
|
||||||
|
QPointF windowPos() const { return scenePosition(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
|
QPointF screenPos() const { return globalPosition(); }
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 0)
|
||||||
|
|
||||||
|
QPointF position() const { return l; }
|
||||||
|
QPointF scenePosition() const { return s; }
|
||||||
|
QPointF globalPosition() const { return g; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPointF l, w, s;
|
QPointF l, s, g;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_GUI_EXPORT QMouseEvent : public QInputEvent
|
class Q_GUI_EXPORT QMouseEvent : public QInputEvent
|
||||||
@ -108,28 +123,44 @@ class Q_GUI_EXPORT QMouseEvent : public QInputEvent
|
|||||||
public:
|
public:
|
||||||
QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
|
QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
|
||||||
QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos,
|
QMouseEvent(Type type, const QPointF &localPos, const QPointF &globalPos,
|
||||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||||
Qt::KeyboardModifiers modifiers);
|
Qt::KeyboardModifiers modifiers);
|
||||||
QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
|
QMouseEvent(Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
|
||||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||||
Qt::KeyboardModifiers modifiers);
|
Qt::KeyboardModifiers modifiers);
|
||||||
QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
|
QMouseEvent(Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
|
||||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||||
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source);
|
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source);
|
||||||
~QMouseEvent();
|
~QMouseEvent();
|
||||||
|
|
||||||
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||||
inline QPoint pos() const { return l.toPoint(); }
|
inline QPoint pos() const { return position().toPoint(); }
|
||||||
inline QPoint globalPos() const { return s.toPoint(); }
|
|
||||||
inline int x() const { return qRound(l.x()); }
|
|
||||||
inline int y() const { return qRound(l.y()); }
|
|
||||||
inline int globalX() const { return qRound(s.x()); }
|
|
||||||
inline int globalY() const { return qRound(s.y()); }
|
|
||||||
#endif
|
#endif
|
||||||
const QPointF &localPos() const { return l; }
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
const QPointF &windowPos() const { return w; }
|
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||||
const QPointF &screenPos() const { return s; }
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
|
inline QPoint globalPos() const { return globalPosition().toPoint(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
|
inline int x() const { return qRound(position().x()); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
|
inline int y() const { return qRound(position().y()); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
|
inline int globalX() const { return qRound(globalPosition().x()); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
|
inline int globalY() const { return qRound(globalPosition().y()); }
|
||||||
|
#endif // QT_NO_INTEGER_EVENT_COORDINATES
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
|
QPointF localPos() const { return position(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()")
|
||||||
|
QPointF windowPos() const { return scenePosition(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
|
QPointF screenPos() const { return globalPosition(); }
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 0)
|
||||||
|
|
||||||
|
QPointF position() const { return l; }
|
||||||
|
QPointF scenePosition() const { return w; }
|
||||||
|
QPointF globalPosition() const { return g; }
|
||||||
|
|
||||||
inline Qt::MouseButton button() const { return b; }
|
inline Qt::MouseButton button() const { return b; }
|
||||||
inline Qt::MouseButtons buttons() const { return mouseState; }
|
inline Qt::MouseButtons buttons() const { return mouseState; }
|
||||||
@ -140,7 +171,7 @@ public:
|
|||||||
Qt::MouseEventFlags flags() const;
|
Qt::MouseEventFlags flags() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPointF l, w, s;
|
QPointF l, w, g;
|
||||||
Qt::MouseButton b;
|
Qt::MouseButton b;
|
||||||
Qt::MouseButtons mouseState;
|
Qt::MouseButtons mouseState;
|
||||||
int caps;
|
int caps;
|
||||||
@ -155,13 +186,21 @@ public:
|
|||||||
QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||||
~QHoverEvent();
|
~QHoverEvent();
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||||
inline QPoint pos() const { return p.toPoint(); }
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
inline QPoint oldPos() const { return op.toPoint(); }
|
inline QPoint pos() const { return position().toPoint(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline const QPointF &posF() const { return p; }
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
inline const QPointF &oldPosF() const { return op; }
|
inline QPointF posF() const { return position(); }
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 0)
|
||||||
|
|
||||||
|
// TODO deprecate when we figure out an actual replacement (point history?)
|
||||||
|
inline QPoint oldPos() const { return op.toPoint(); }
|
||||||
|
inline QPointF oldPosF() const { return op; }
|
||||||
|
|
||||||
|
QPointF position() const { return p; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPointF p, op;
|
QPointF p, op;
|
||||||
@ -224,16 +263,31 @@ public:
|
|||||||
Qt::MouseButton button, Qt::MouseButtons buttons);
|
Qt::MouseButton button, Qt::MouseButtons buttons);
|
||||||
~QTabletEvent();
|
~QTabletEvent();
|
||||||
|
|
||||||
inline QPoint pos() const { return mPos.toPoint(); }
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
inline QPoint globalPos() const { return mGPos.toPoint(); }
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
|
inline QPoint pos() const { return position().toPoint(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
|
inline QPoint globalPos() const { return globalPosition().toPoint(); }
|
||||||
|
|
||||||
inline const QPointF &posF() const { return mPos; }
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
inline const QPointF &globalPosF() const { return mGPos; }
|
inline const QPointF posF() const { return position(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
inline int x() const { return qRound(mPos.x()); }
|
inline const QPointF globalPosF() const { return globalPosition(); }
|
||||||
inline int y() const { return qRound(mPos.y()); }
|
QT_DEPRECATED_VERSION_X_6_0("Use position().x()")
|
||||||
inline int globalX() const { return qRound(mGPos.x()); }
|
inline int x() const { return qRound(position().x()); }
|
||||||
inline int globalY() const { return qRound(mGPos.y()); }
|
QT_DEPRECATED_VERSION_X_6_0("Use position().y()")
|
||||||
|
inline int y() const { return qRound(position().y()); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition().x()")
|
||||||
|
inline int globalX() const { return qRound(globalPosition().x()); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition().y()")
|
||||||
|
inline int globalY() const { return qRound(globalPosition().y()); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("use globalPosition().x()")
|
||||||
|
inline qreal hiResGlobalX() const { return globalPosition().x(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("use globalPosition().y()")
|
||||||
|
inline qreal hiResGlobalY() const { return globalPosition().y(); }
|
||||||
|
#endif
|
||||||
|
inline QPointF position() const { return mPos; }
|
||||||
|
inline QPointF globalPosition() const { return mGPos; }
|
||||||
inline TabletDevice deviceType() const { return TabletDevice(mDev); }
|
inline TabletDevice deviceType() const { return TabletDevice(mDev); }
|
||||||
inline PointerType pointerType() const { return PointerType(mPointerType); }
|
inline PointerType pointerType() const { return PointerType(mPointerType); }
|
||||||
inline qint64 uniqueId() const { return mUnique; }
|
inline qint64 uniqueId() const { return mUnique; }
|
||||||
@ -262,27 +316,38 @@ protected:
|
|||||||
class Q_GUI_EXPORT QNativeGestureEvent : public QInputEvent
|
class Q_GUI_EXPORT QNativeGestureEvent : public QInputEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *dev, const QPointF &localPos, const QPointF &windowPos,
|
QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *dev, const QPointF &localPos, const QPointF &scenePos,
|
||||||
const QPointF &screenPos, qreal value, ulong sequenceId, quint64 intArgument);
|
const QPointF &globalPos, qreal value, ulong sequenceId, quint64 intArgument);
|
||||||
~QNativeGestureEvent();
|
~QNativeGestureEvent();
|
||||||
Qt::NativeGestureType gestureType() const { return mGestureType; }
|
Qt::NativeGestureType gestureType() const { return mGestureType; }
|
||||||
qreal value() const { return mRealValue; }
|
qreal value() const { return mRealValue; }
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||||
inline const QPoint pos() const { return mLocalPos.toPoint(); }
|
QT_DEPRECATED_VERSION_X_6_0("Use position().toPoint()")
|
||||||
inline const QPoint globalPos() const { return mScreenPos.toPoint(); }
|
inline const QPoint pos() const { return position().toPoint(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition().toPoint()")
|
||||||
|
inline const QPoint globalPos() const { return globalPosition().toPoint(); }
|
||||||
#endif
|
#endif
|
||||||
const QPointF &localPos() const { return mLocalPos; }
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
const QPointF &windowPos() const { return mWindowPos; }
|
QPointF localPos() const { return position(); }
|
||||||
const QPointF &screenPos() const { return mScreenPos; }
|
QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()")
|
||||||
|
QPointF windowPos() const { return scenePosition(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
|
QPointF screenPos() const { return globalPosition(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QPointF position() const { return mLocalPos; }
|
||||||
|
QPointF scenePosition() const { return mScenePos; }
|
||||||
|
QPointF globalPosition() const { return mGlobalPos; }
|
||||||
|
|
||||||
const QTouchDevice *device() const { return mDevice; }
|
const QTouchDevice *device() const { return mDevice; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Qt::NativeGestureType mGestureType;
|
Qt::NativeGestureType mGestureType;
|
||||||
QPointF mLocalPos;
|
QPointF mLocalPos;
|
||||||
QPointF mWindowPos;
|
QPointF mScenePos;
|
||||||
QPointF mScreenPos;
|
QPointF mGlobalPos;
|
||||||
qreal mRealValue;
|
qreal mRealValue;
|
||||||
ulong mSequenceId;
|
ulong mSequenceId;
|
||||||
quint64 mIntValue;
|
quint64 mIntValue;
|
||||||
@ -551,10 +616,20 @@ public:
|
|||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
|
||||||
~QDropEvent();
|
~QDropEvent();
|
||||||
|
|
||||||
inline QPoint pos() const { return p.toPoint(); }
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
inline const QPointF &posF() const { return p; }
|
QT_DEPRECATED_VERSION_X_6_0("Use position().toPoint()")
|
||||||
inline Qt::MouseButtons mouseButtons() const { return mouseState; }
|
inline QPoint pos() const { return position().toPoint(); }
|
||||||
inline Qt::KeyboardModifiers keyboardModifiers() const { return modState; }
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
|
inline QPointF posF() const { return position(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use buttons()")
|
||||||
|
inline Qt::MouseButtons mouseButtons() const { return buttons(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use modifiers()")
|
||||||
|
inline Qt::KeyboardModifiers keyboardModifiers() const { return modifiers(); }
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 0)
|
||||||
|
|
||||||
|
QPointF position() const { return p; }
|
||||||
|
inline Qt::MouseButtons buttons() const { return mouseState; }
|
||||||
|
inline Qt::KeyboardModifiers modifiers() const { return modState; }
|
||||||
|
|
||||||
inline Qt::DropActions possibleActions() const { return act; }
|
inline Qt::DropActions possibleActions() const { return act; }
|
||||||
inline Qt::DropAction proposedAction() const { return default_action; }
|
inline Qt::DropAction proposedAction() const { return default_action; }
|
||||||
@ -809,22 +884,40 @@ public:
|
|||||||
|
|
||||||
Qt::TouchPointState state() const;
|
Qt::TouchPointState state() const;
|
||||||
|
|
||||||
QPointF pos() const;
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
QPointF startPos() const;
|
QT_DEPRECATED_VERSION_X_6_0("Use position()")
|
||||||
QPointF lastPos() const;
|
QPointF pos() const { return position(); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use pressPosition()")
|
||||||
|
QPointF startPos() const { return pressPosition(); }
|
||||||
|
|
||||||
QPointF scenePos() const;
|
QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()")
|
||||||
QPointF startScenePos() const;
|
QPointF scenePos() const { return scenePosition(); }
|
||||||
QPointF lastScenePos() const;
|
QT_DEPRECATED_VERSION_X_6_0("Use scenePressPosition()")
|
||||||
|
QPointF startScenePos() const { return scenePressPosition(); }
|
||||||
|
|
||||||
QPointF screenPos() const;
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
|
||||||
QPointF startScreenPos() const;
|
QPointF screenPos() const { return globalPosition(); }
|
||||||
QPointF lastScreenPos() const;
|
QT_DEPRECATED_VERSION_X_6_0("Use globalPressPosition()")
|
||||||
|
QPointF startScreenPos() const { return globalPressPosition(); }
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 0)
|
||||||
|
|
||||||
|
// TODO deprecate these after finding good replacements (use QPointingDevice::globalArea?)
|
||||||
QPointF normalizedPos() const;
|
QPointF normalizedPos() const;
|
||||||
QPointF startNormalizedPos() const;
|
QPointF startNormalizedPos() const;
|
||||||
|
|
||||||
|
// TODO deprecate these after finding good replacements (store longer history perhaps?)
|
||||||
|
QPointF lastPos() const;
|
||||||
|
QPointF lastScenePos() const;
|
||||||
|
QPointF lastScreenPos() const;
|
||||||
QPointF lastNormalizedPos() const;
|
QPointF lastNormalizedPos() const;
|
||||||
|
|
||||||
|
QPointF position() const;
|
||||||
|
QPointF pressPosition() const;
|
||||||
|
QPointF scenePosition() const;
|
||||||
|
QPointF scenePressPosition() const;
|
||||||
|
QPointF globalPosition() const;
|
||||||
|
QPointF globalPressPosition() const;
|
||||||
|
|
||||||
qreal pressure() const;
|
qreal pressure() const;
|
||||||
qreal rotation() const;
|
qreal rotation() const;
|
||||||
QSizeF ellipseDiameters() const;
|
QSizeF ellipseDiameters() const;
|
||||||
@ -834,6 +927,8 @@ public:
|
|||||||
QVector<QPointF> rawScreenPositions() const;
|
QVector<QPointF> rawScreenPositions() const;
|
||||||
|
|
||||||
// internal
|
// internal
|
||||||
|
// ### Qt 6: move private, rename appropriately, only friends can call them
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
void setId(int id);
|
void setId(int id);
|
||||||
void setUniqueId(qint64 uid);
|
void setUniqueId(qint64 uid);
|
||||||
void setState(Qt::TouchPointStates state);
|
void setState(Qt::TouchPointStates state);
|
||||||
@ -855,6 +950,7 @@ public:
|
|||||||
void setVelocity(const QVector2D &v);
|
void setVelocity(const QVector2D &v);
|
||||||
void setFlags(InfoFlags flags);
|
void setFlags(InfoFlags flags);
|
||||||
void setRawScreenPositions(const QVector<QPointF> &positions);
|
void setRawScreenPositions(const QVector<QPointF> &positions);
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 0)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTouchEventTouchPointPrivate *d;
|
QTouchEventTouchPointPrivate *d;
|
||||||
@ -879,12 +975,14 @@ public:
|
|||||||
inline const QList<QTouchEvent::TouchPoint> &touchPoints() const { return _touchPoints; }
|
inline const QList<QTouchEvent::TouchPoint> &touchPoints() const { return _touchPoints; }
|
||||||
inline QTouchDevice *device() const { return _device; }
|
inline QTouchDevice *device() const { return _device; }
|
||||||
|
|
||||||
// internal
|
// ### Qt 6: move private, rename appropriately, only friends can call them; or just let friends modify variables directly
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
inline void setWindow(QWindow *awindow) { _window = awindow; }
|
inline void setWindow(QWindow *awindow) { _window = awindow; }
|
||||||
inline void setTarget(QObject *atarget) { _target = atarget; }
|
inline void setTarget(QObject *atarget) { _target = atarget; }
|
||||||
inline void setTouchPointStates(Qt::TouchPointStates aTouchPointStates) { _touchPointStates = aTouchPointStates; }
|
inline void setTouchPointStates(Qt::TouchPointStates aTouchPointStates) { _touchPointStates = aTouchPointStates; }
|
||||||
inline void setTouchPoints(const QList<QTouchEvent::TouchPoint> &atouchPoints) { _touchPoints = atouchPoints; }
|
inline void setTouchPoints(const QList<QTouchEvent::TouchPoint> &atouchPoints) { _touchPoints = atouchPoints; }
|
||||||
inline void setDevice(QTouchDevice *adevice) { _device = adevice; }
|
inline void setDevice(QTouchDevice *adevice) { _device = adevice; }
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 0)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QWindow *_window;
|
QWindow *_window;
|
||||||
|
Loading…
Reference in New Issue
Block a user