(1)本 QEventPoint 类的引出 :
(2)本源码定义于头文件 qeventpoint . h :
#ifndef QEVENTPOINT_H
#define QEVENTPOINT_H
#include <QtGui/qtguiglobal.h>
#include <QtGui/qvector2d.h>
#include <QtGui/qpointingdevice.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qmetatype.h>
QT_BEGIN_NAMESPACE
class QEventPointPrivate;
QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QEventPointPrivate, Q_GUI_EXPORT)
class QMutableEventPoint;
/*
The QEventPoint class provides information about a point in a QPointerEvent.
无详细注释
*/
class Q_GUI_EXPORT QEventPoint //本类内容多,因为添加了对触摸屏的支持,而不仅仅是鼠标
{
Q_GADGET
//此属性持有事件点的接受状态。
//在基于小部件的应用程序中,此属性不使用,因为它仅对小部件接受或拒绝完整的QInputEvent有意义。
//然而在QtQuick中,一个项或事件处理程序通常只接受QTouchEvent中实际参与手势的个别点,
// 而其他点可以传递给其他项或处理程序。为了保持一致性,这同样适用于任何QPointerEvent;
// 只有当OPointerEvent中的所有点都被接受后,才会执行传递操作。
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
QDOC_PROPERTY(QPointingDevice * device READ device CONSTANT) // qdoc doesn't know const
Q_PROPERTY(const QPointingDevice * device READ device CONSTANT)
//此属性持有该事件点的ID编号。
//注:不要假定ID号从0开始,也不要假定它们是按顺序排列的。
//由于底层驱动程序的工作方式,这种假设往往是错误的。
Q_PROPERTY(int id READ id CONSTANT)
//此属性包含此点或令牌的唯一ID(如果有)。
//它通常无效(见isValid()),因为触摸屏无法唯一识别手指。
//当它来自QTabletEvent时,它可以识别正在使用的触控笔的序列号。
//当使用支持这些功能的触摸屏时,TUIO驱动程序可能会识别特定的令牌(基准对象)
Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId CONSTANT)
//This property holds the current state of the event point.
Q_PROPERTY(State state READ state CONSTANT)
//此属性表示该点最近一次被包含在QPointerEvent中的时间。
Q_PROPERTY(ulong timestamp READ timestamp CONSTANT)
//此属性保存了该点最近一次被按下的时间。
Q_PROPERTY(ulong pressTimestamp READ pressTimestamp CONSTANT)
Q_PROPERTY(ulong lastTimestamp READ lastTimestamp CONSTANT)
//此属性表示从包含该点的上一个QPointerEvent事件的时间。
Q_PROPERTY(qreal timeHeld READ timeHeld CONSTANT)
// /此属性持有自该点被按下且未释放以来的持续时间,以毫秒为单位。
//此属性表示该点的压力。 返回值在范围[0.0 到 1.0]内。
Q_PROPERTY(qreal pressure READ pressure CONSTANT)
Q_PROPERTY(qreal rotation READ rotation CONSTANT)
//此属性表示该点的角方向。 返回值以度数表示,
//其中零(默认值)表示手指、令牌或触控笔指向上方,
//负角度数表示它已旋转至左侧,而正角度数表示它已旋转至右侧。
//大多数触摸屏并不检测旋转,因此零是最常见的值。
//此属性包含触摸点边界椭圆的宽度和高度。
//返回值以逻辑像素为单位。大多数触屏设备并不检测接触点的形状,也没有鼠标或平板电脑设备能够检测到这点,
// 因此“零尺寸”是最常见的值。
//在某些触屏设备上,直径可能不为零,且始终保持相等(即,椭圆被近似处理为圆形)。
Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters CONSTANT)
//此属性持有速度向量,以每秒像素为单位,在屏幕或桌面的坐标系统中。
//注意:如果设备的功能包括OInputDevice::Velocity,
// 则表示速度来自操作系统(可能由触摸硬件或驱动程序提供)。
//但通常没有设置Velocity功能,表明Velocitv是通过Qt计算的,
// 使用简单的卡尔曼滤波器提供平滑的平均Velocity而不是瞬时值。
//它有效地告诉了用户在最近几次事件中拖动这个点的速度和方向,最近一次事件的影响最大。
Q_PROPERTY(QVector2D velocity READ velocity CONSTANT)
//此属性持有该点的位置。该位置相对于接收事件的组件或项目。以下无另外说明,返回的都是相对坐标。
Q_PROPERTY(QPointF position READ position CONSTANT)
//此属性持有该点被按下时的位置。
Q_PROPERTY(QPointF pressPosition READ pressPosition CONSTANT)
//This property holds the position at which this point was grabbed.
Q_PROPERTY(QPointF grabPosition READ grabPosition CONSTANT)
//此属性保存了该点相对于上一次按下或移动事件的位置。
Q_PROPERTY(QPointF lastPosition READ lastPosition CONSTANT)
//此属性持有该点的场景位置。
//如果在 QQQuickItem::event()中处理,则场景位置是相对于QQuickWindow的位置,
//如果由 QGraphicsltem::touchEvent()的覆盖处理,则在 QGraphicsScene坐标中,
//或小部件应用程序中的窗口位置。
Q_PROPERTY(QPointF scenePosition READ scenePosition CONSTANT)
Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition CONSTANT)
Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition CONSTANT)
Q_PROPERTY(QPointF sceneLastPosition READ sceneLastPosition CONSTANT)
//此属性持有该点的全局位置。 全局位置相对于屏幕或虚拟桌面。
Q_PROPERTY(QPointF globalPosition READ globalPosition CONSTANT)
Q_PROPERTY(QPointF globalPressPosition READ globalPressPosition CONSTANT)
Q_PROPERTY(QPointF globalGrabPosition READ globalGrabPosition CONSTANT)
Q_PROPERTY(QPointF globalLastPosition READ globalLastPosition CONSTANT)
private:
QExplicitlySharedDataPointer<QEventPointPrivate> d;
friend class QMutableEventPoint;
friend class QPointerEvent;
public:
explicit
QEventPoint(int id = -1, const QPointingDevice * device = nullptr);
QEventPoint( int pointId, State state,
const QPointF & scenePosition, const QPointF & globalPosition);
QEventPoint(const QEventPoint & other) noexcept;
QEventPoint & operator= (const QEventPoint & other) noexcept;
QEventPoint(QEventPoint && other) noexcept = default;
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QEventPoint)
~QEventPoint();
bool operator==(const QEventPoint & other) const noexcept;
bool operator!=(const QEventPoint & other) const noexcept
{ return !operator==(other); }
inline void swap(QEventPoint &other) noexcept
{ qSwap(d, other.d); }
bool isAccepted() const; //以下全是属性函数
void setAccepted(bool accepted = true);
const QPointingDevice * device() const;
int id() const;
QPointingDeviceUniqueId uniqueId() const;
//Specifies the state of this event point.
enum State : quint8 {
Unknown = Qt::TouchPointUnknownState, //Unknown state.
Stationary = Qt::TouchPointStationary, //The event point did not move.
Pressed = Qt::TouchPointPressed, //The touch point or button is pressed.
Updated = Qt::TouchPointMoved, //The event point was updated.
Released = Qt::TouchPointReleased //The touch point or button was released.
};
Q_DECLARE_FLAGS(States, State)
Q_FLAG(States)
State state() const;
ulong timestamp() const;
ulong lastTimestamp() const;
ulong pressTimestamp() const;
qreal timeHeld () const;
qreal pressure() const;
qreal rotation() const;
QSizeF ellipseDiameters() const;
QVector2D velocity() const;
QPointF position() const; //这些函数对应属性,明了,不注释了。
QPointF pressPosition() const;
QPointF grabPosition() const;
QPointF lastPosition() const;
QPointF scenePosition() const;
QPointF scenePressPosition() const;
QPointF sceneGrabPosition() const;
QPointF sceneLastPosition() const;
QPointF globalPosition() const;
QPointF globalPressPosition() const;
QPointF globalGrabPosition() const;
QPointF globalLastPosition() const;
QPointF normalizedPosition() const;
}; //完结 class QEventPoint
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QEventPoint *);
Q_GUI_EXPORT QDebug operator<<(QDebug, const QEventPoint &);
#endif
Q_DECLARE_SHARED(QEventPoint)
QT_END_NAMESPACE
#endif // QEVENTPOINT_H
(3)
谢谢