10#if QT_CONFIG(graphicsview)
27#if (defined(Q_OS_MACOS) || defined(Q_OS_WIN)) && !defined(QT_NO_NATIVE_GESTURES)
29 if (!qobject_cast<QAbstractScrollArea *>(
target->parent()))
43 result += touchPoints.at(
p).position() - touchPoints.at(
p).pressPosition();
55 switch (
event->type()) {
59 d->pointCount = m_pointCount;
65 if (ev->points().size() ==
d->pointCount) {
66 d->lastOffset =
d->offset;
77 if (ev->points().size() >=
d->pointCount) {
78 d->lastOffset =
d->offset;
80 if (
d->offset.x() > 10 ||
d->offset.y() > 10 ||
81 d->offset.x() < -10 ||
d->offset.y() < -10) {
82 q->setHotSpot(ev->points().first().globalPressPosition());
133 switch (
event->type()) {
148 d->changeFlags = { };
149 if (ev->points().size() == 2) {
153 d->hotSpot =
p1.globalPosition();
154 d->isHotSpotSet =
true;
156 QPointF centerPoint = (
p1.globalPosition() +
p2.globalPosition()) / 2.0;
157 if (
d->isNewSequence) {
158 d->startPosition[0] =
p1.globalPosition();
159 d->startPosition[1] =
p2.globalPosition();
160 d->lastCenterPoint = centerPoint;
162 d->lastCenterPoint =
d->centerPoint;
164 d->centerPoint = centerPoint;
168 if (
d->isNewSequence) {
169 d->scaleFactor = 1.0;
170 d->lastScaleFactor = 1.0;
172 d->lastScaleFactor =
d->scaleFactor;
174 QLineF lastLine(
p1.globalLastPosition(),
p2.globalLastPosition());
178 d->scaleFactor = newScaleFactor;
180 d->totalScaleFactor =
d->totalScaleFactor *
d->scaleFactor;
187 if (startAngle > 180)
189 const qreal rotationAngle = startAngle -
angle;
190 if (
d->isNewSequence)
191 d->lastRotationAngle = 0.0;
193 d->lastRotationAngle =
d->rotationAngle;
194 d->rotationAngle = rotationAngle;
195 d->totalRotationAngle +=
d->rotationAngle -
d->lastRotationAngle;
198 d->totalChangeFlags |=
d->changeFlags;
199 d->isNewSequence =
false;
202 d->isNewSequence =
true;
223 d->startCenterPoint =
d->lastCenterPoint =
d->centerPoint =
QPointF();
224 d->totalScaleFactor =
d->lastScaleFactor =
d->scaleFactor = 1;
225 d->totalRotationAngle =
d->lastRotationAngle =
d->rotationAngle = 0;
227 d->isNewSequence =
true;
228 d->startPosition[0] =
d->startPosition[1] =
QPointF();
258 switch (
event->type()) {
278 else if (ev->points().size() == 3) {
284 if (
d->lastPositions[0].isNull()) {
285 d->lastPositions[0] =
p1.globalPressPosition().toPoint();
286 d->lastPositions[1] =
p2.globalPressPosition().toPoint();
287 d->lastPositions[2] = p3.globalPressPosition().toPoint();
289 d->hotSpot =
p1.globalPosition();
290 d->isHotSpotSet =
true;
292 int xDistance = (
p1.globalPosition().x() -
d->lastPositions[0].x() +
293 p2.globalPosition().x() -
d->lastPositions[1].x() +
294 p3.globalPosition().x() -
d->lastPositions[2].x()) / 3;
295 int yDistance = (
p1.globalPosition().y() -
d->lastPositions[0].y() +
296 p2.globalPosition().y() -
d->lastPositions[1].y() +
297 p3.globalPosition().y() -
d->lastPositions[2].y()) / 3;
299 const int distance = xDistance >= yDistance ? xDistance : yDistance;
300 int elapsedTime =
d->time.restart();
303 d->velocityValue = 0.9 *
d->velocityValue + (
qreal)
distance / elapsedTime;
304 d->swipeAngle =
QLineF(
p1.globalPressPosition(),
p1.globalPosition()).
angle();
306 static const int MoveThreshold = 50;
307 static const int directionChangeThreshold = MoveThreshold / 8;
308 if (
qAbs(xDistance) > MoveThreshold ||
qAbs(yDistance) > MoveThreshold) {
310 d->lastPositions[0] =
p1.globalPosition().toPoint();
311 d->lastPositions[1] =
p2.globalPosition().toPoint();
312 d->lastPositions[2] = p3.globalPosition().toPoint();
320 d->verticalDirection = vertical;
327 d->horizontalDirection = horizontal;
335 }
else if (ev->points().size() > 3) {
367 d->lastPositions[0] =
d->lastPositions[1] =
d->lastPositions[2] =
QPoint();
369 d->velocityValue = 0;
370 d->time.invalidate();
402 switch (
event->type()) {
405 q->setHotSpot(ev->points().at(0).globalPosition());
413 QPoint delta =
p.position().toPoint() -
p.pressPosition().toPoint();
414 enum { TapRadius = 40 };
462QGestureRecognizer::Result
470 q->killTimer(
d->timerId);
475 enum { TapRadius = 40 };
477 switch (
event->type()) {
478#if QT_CONFIG(graphicsview)
482 q->setHotSpot(
d->position);
484 q->killTimer(
d->timerId);
492 q->setHotSpot(
d->position);
494 q->killTimer(
d->timerId);
501 q->setHotSpot(
d->position);
503 q->killTimer(
d->timerId);
507#if QT_CONFIG(graphicsview)
515 if (
d->timerId && ev->points().size() == 1) {
517 QPoint delta =
p.position().toPoint() -
p.pressPosition().toPoint();
530#if QT_CONFIG(graphicsview)
533 QPoint delta = gsme->screenPos() -
d->position.toPoint();
551 q->killTimer(
d->timerId);
The QEventPoint class provides information about a point in a QPointerEvent.
QPointF globalPressPosition
the global position at which this point was pressed.
QPointF position
the position of this point.
@ GraphicsSceneMouseRelease
@ GraphicsSceneMousePress
virtual void reset(QGesture *state)
This function is called by the framework to reset a given gesture.
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
QPoint screenPos() const
Returns the mouse cursor position in screen coordinates.
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
const_reference at(qsizetype i) const noexcept
QGesture * create(QObject *target) override
This function is called by Qt to create a new QGesture object for the given target (QWidget or QGraph...
void reset(QGesture *state) override
This function is called by the framework to reset a given gesture.
QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override
Handles the given event for the watched object, updating the state of the gesture object as required,...
The QPanGesture class describes a panning gesture made by the user.\inmodule QtWidgets.
QPointF lastOffset
the last offset recorded for this gesture
QGesture * create(QObject *target) override
This function is called by Qt to create a new QGesture object for the given target (QWidget or QGraph...
QPinchGestureRecognizer()
QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override
Handles the given event for the watched object, updating the state of the gesture object as required,...
void reset(QGesture *state) override
This function is called by the framework to reset a given gesture.
The QPinchGesture class describes a pinch gesture made by the user.\inmodule QtWidgets.
ChangeFlags totalChangeFlags
the property of the gesture that has change
\inmodule QtCore\reentrant
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr int manhattanLength() const
Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" ...
const QList< QEventPoint > & points() const
Returns a list of points in this pointer event.
QPointF globalPosition() const
Returns the position of the point in this event on the screen or virtual desktop.
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
qsizetype length() const noexcept
Returns the number of characters in this string.
QSwipeGesture::SwipeDirection verticalDirection
QGesture * create(QObject *target) override
This function is called by Qt to create a new QGesture object for the given target (QWidget or QGraph...
QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override
Handles the given event for the watched object, updating the state of the gesture object as required,...
void reset(QGesture *state) override
This function is called by the framework to reset a given gesture.
QSwipeGestureRecognizer()
The QSwipeGesture class describes a swipe gesture made by the user.\inmodule QtWidgets.
SwipeDirection
This enum describes the possible directions for the gesture's motion along the horizontal and vertica...
QTapAndHoldGestureRecognizer()
void reset(QGesture *state) override
This function is called by the framework to reset a given gesture.
QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override
Handles the given event for the watched object, updating the state of the gesture object as required,...
QGesture * create(QObject *target) override
This function is called by Qt to create a new QGesture object for the given target (QWidget or QGraph...
The QTapAndHoldGesture class describes a tap-and-hold (aka LongTap) gesture made by the user....
void reset(QGesture *state) override
This function is called by the framework to reset a given gesture.
QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override
Handles the given event for the watched object, updating the state of the gesture object as required,...
QGesture * create(QObject *target) override
This function is called by Qt to create a new QGesture object for the given target (QWidget or QGraph...
The QTapGesture class describes a tap gesture made by the user.\inmodule QtWidgets.
The QTouchEvent class contains parameters that describe a touch event.
Combined button and popup list for selecting options.
constexpr const T & qMin(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLenum GLenum GLsizei count
GLsizei GLsizei GLfloat distance
GLdouble GLdouble GLdouble GLdouble q
static QPointF panOffset(const QList< QEventPoint > &touchPoints, int maxCount)
static QT_BEGIN_NAMESPACE const qreal kSingleStepScaleMax
static const qreal kSingleStepScaleMin
app setAttribute(Qt::AA_DontShowIconsInMenus)