Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickpincharea.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "qquickwindow.h"
6
7#include <QtCore/qmath.h>
8#include <QtGui/qevent.h>
9#include <QtGui/qguiapplication.h>
10#include <QtGui/qstylehints.h>
11#include <qpa/qplatformintegration.h>
12#include <qpa/qplatformnativeinterface.h>
13#include <private/qguiapplication_p.h>
14#include <QVariant>
15
16#include <float.h>
17
19
20Q_LOGGING_CATEGORY(lcPA, "qt.quick.pincharea")
21
22
120 : m_target(nullptr), m_minScale(1.0), m_maxScale(1.0)
121 , m_minRotation(0.0), m_maxRotation(0.0)
122 , m_axis(NoDrag), m_xmin(-FLT_MAX), m_xmax(FLT_MAX)
123 , m_ymin(-FLT_MAX), m_ymax(FLT_MAX), m_active(false)
124{
125}
126
131
245 : QQuickItem(*(new QQuickPinchAreaPrivate), parent)
246{
247 Q_D(QQuickPinchArea);
248 d->init();
250#ifdef Q_OS_MACOS
251 setAcceptHoverEvents(true); // needed to enable touch events on mouse hover.
252#endif
253}
254
265{
266 Q_D(const QQuickPinchArea);
267 return d->enabled;
268}
269
271{
272 Q_D(QQuickPinchArea);
273 if (a != d->enabled) {
274 d->enabled = a;
276 }
277}
278
280{
281 Q_D(QQuickPinchArea);
282 if (!d->enabled || !isVisible()) {
284 return;
285 }
286
287 // A common non-trivial starting scenario is the user puts down one finger,
288 // then that finger remains stationary while putting down a second one.
289 // However QQuickWindow will not send TouchUpdates for TouchPoints which
290 // were not initially accepted; that would be inefficient and noisy.
291 // So even if there is only one touchpoint so far, it's important to accept it
292 // in order to get updates later on (and it's accepted by default anyway).
293 // If the user puts down one finger, we're waiting for the other finger to drop.
294 // Therefore updatePinch() must do the right thing for any combination of
295 // points and states that may occur, and there is no reason to ignore any event.
296 // One consequence though is that if PinchArea is on top of something else,
297 // it's always going to accept the touches, and that means the item underneath
298 // will not get them (unless the PA's parent is doing parent filtering,
299 // as the Flickable does, for example).
300 switch (event->type()) {
303 d->touchPoints.clear();
304 for (int i = 0; i < event->pointCount(); ++i) {
305 auto &tp = event->point(i);
306 if (tp.state() != QEventPoint::State::Released) {
307 d->touchPoints << tp;
308 tp.setAccepted();
309 }
310 }
311 updatePinch(event, false);
312 break;
313 case QEvent::TouchEnd:
314 clearPinch(event);
315 break;
317 cancelPinch(event);
318 break;
319 default:
321 }
322}
323
324void QQuickPinchArea::clearPinch(QTouchEvent *event)
325{
326 Q_D(QQuickPinchArea);
327 qCDebug(lcPA, "clear: %" PRIdQSIZETYPE " touchpoints", d->touchPoints.size());
328 d->touchPoints.clear();
329 if (d->inPinch) {
330 d->inPinch = false;
331 QPointF pinchCenter = mapFromScene(d->sceneLastCenter);
332 QQuickPinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, d->pinchRotation);
333 pe.setStartCenter(d->pinchStartCenter);
334 pe.setPreviousCenter(pinchCenter);
335 pe.setPreviousAngle(d->pinchLastAngle);
336 pe.setPreviousScale(d->pinchLastScale);
337 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
338 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
339 pe.setPoint1(mapFromScene(d->lastPoint1));
340 pe.setPoint2(mapFromScene(d->lastPoint2));
341 emit pinchFinished(&pe);
342 if (d->pinch && d->pinch->target())
343 d->pinch->setActive(false);
344 }
345 d->pinchStartDist = 0;
346 d->pinchActivated = false;
347 d->initPinch = false;
348 d->pinchRejected = false;
349 d->id1 = -1;
350 if (event) {
351 for (const auto &point : event->points()) {
352 if (event->exclusiveGrabber(point) == this)
353 event->setExclusiveGrabber(point, nullptr);
354 }
355 }
356 setKeepTouchGrab(false);
357 setKeepMouseGrab(false);
358}
359
360void QQuickPinchArea::cancelPinch(QTouchEvent *event)
361{
362 Q_D(QQuickPinchArea);
363 qCDebug(lcPA, "cancel: %" PRIdQSIZETYPE " touchpoints", d->touchPoints.size());
364 d->touchPoints.clear();
365 if (d->inPinch) {
366 d->inPinch = false;
367 QPointF pinchCenter = mapFromScene(d->sceneLastCenter);
368 QQuickPinchEvent pe(d->pinchStartCenter, d->pinchStartScale, d->pinchStartAngle, d->pinchStartRotation);
369 pe.setStartCenter(d->pinchStartCenter);
370 pe.setPreviousCenter(pinchCenter);
371 pe.setPreviousAngle(d->pinchLastAngle);
372 pe.setPreviousScale(d->pinchLastScale);
373 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
374 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
375 pe.setPoint1(pe.startPoint1());
376 pe.setPoint2(pe.startPoint2());
377 emit pinchFinished(&pe);
378
379 d->pinchLastScale = d->pinchStartScale;
380 d->sceneLastCenter = d->sceneStartCenter;
381 d->pinchLastAngle = d->pinchStartAngle;
382 d->lastPoint1 = pe.startPoint1();
383 d->lastPoint2 = pe.startPoint2();
384 updatePinchTarget();
385
386 if (d->pinch && d->pinch->target())
387 d->pinch->setActive(false);
388 }
389 d->pinchStartDist = 0;
390 d->pinchActivated = false;
391 d->initPinch = false;
392 d->pinchRejected = false;
393 d->id1 = -1;
394 for (const auto &point : event->points()) {
395 if (event->exclusiveGrabber(point) == this)
396 event->setExclusiveGrabber(point, nullptr);
397 }
398 setKeepTouchGrab(false);
399 setKeepMouseGrab(false);
400}
401
402void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
403{
404 Q_D(QQuickPinchArea);
405
406 if (d->touchPoints.size() < 2) {
407 // A pinch gesture is not occurring, so stealing the grab is permitted.
408 setKeepTouchGrab(false);
409 setKeepMouseGrab(false);
410 // During filtering, there's no need to hold a grab for one point,
411 // because filtering happens for every event anyway.
412 // But if we receive the event via direct delivery, and give up the grab,
413 // not only will we not see any more updates, but any filtering parent
414 // (such as Flickable) will also not get a chance to filter them.
415 // Continuing to hold the grab in this case keeps tst_TouchMouse::pinchOnFlickable() working.
416 if (filtering && !d->touchPoints.isEmpty() && event->exclusiveGrabber(d->touchPoints.first()) == this)
417 event->setExclusiveGrabber(d->touchPoints.first(), nullptr);
418 }
419
420 if (d->touchPoints.size() == 0) {
421 if (d->inPinch) {
422 d->inPinch = false;
423 QPointF pinchCenter = mapFromScene(d->sceneLastCenter);
424 QQuickPinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, d->pinchRotation);
425 pe.setStartCenter(d->pinchStartCenter);
426 pe.setPreviousCenter(pinchCenter);
427 pe.setPreviousAngle(d->pinchLastAngle);
428 pe.setPreviousScale(d->pinchLastScale);
429 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
430 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
431 pe.setPoint1(mapFromScene(d->lastPoint1));
432 pe.setPoint2(mapFromScene(d->lastPoint2));
433 setKeepTouchGrab(false);
434 setKeepMouseGrab(false);
435 emit pinchFinished(&pe);
436 d->pinchStartDist = 0;
437 d->pinchActivated = false;
438 if (d->pinch && d->pinch->target())
439 d->pinch->setActive(false);
440 }
441 d->initPinch = false;
442 d->pinchRejected = false;
443 return;
444 }
445
446 QEventPoint touchPoint1 = d->touchPoints.at(0);
447 QEventPoint touchPoint2 = d->touchPoints.at(d->touchPoints.size() >= 2 ? 1 : 0);
448
449 if (touchPoint1.state() == QEventPoint::State::Pressed)
450 d->sceneStartPoint1 = touchPoint1.scenePosition();
451
452 if (touchPoint2.state() == QEventPoint::State::Pressed)
453 d->sceneStartPoint2 = touchPoint2.scenePosition();
454
455 qCDebug(lcPA) << "updating based on" << touchPoint1 << touchPoint2;
456
457 QRectF bounds = clipRect();
458 // Pinch is not started unless there are exactly two touch points
459 // AND one or more of the points has just now been pressed (wasn't pressed already)
460 // AND both points are inside the bounds.
461 if (d->touchPoints.size() == 2
462 && (touchPoint1.state() == QEventPoint::State::Pressed || touchPoint2.state() == QEventPoint::State::Pressed) &&
463 bounds.contains(touchPoint1.position()) && bounds.contains(touchPoint2.position())) {
464 d->id1 = touchPoint1.id();
465 if (!d->pinchActivated)
466 qCDebug(lcPA, "pinch activating");
467 d->pinchActivated = true;
468 d->initPinch = true;
469 event->setExclusiveGrabber(touchPoint1, this);
470 event->setExclusiveGrabber(touchPoint2, this);
471 setKeepTouchGrab(true);
472 setKeepMouseGrab(true);
473 }
474 if (d->pinchActivated && !d->pinchRejected) {
475 const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
476 QPointF p1 = touchPoint1.scenePosition();
477 QPointF p2 = touchPoint2.scenePosition();
478 qreal dx = p1.x() - p2.x();
479 qreal dy = p1.y() - p2.y();
480 qreal dist = qSqrt(dx*dx + dy*dy);
481 QPointF sceneCenter = (p1 + p2)/2;
482 qreal angle = QLineF(p1, p2).angle();
483 if (d->touchPoints.size() == 1) {
484 // If we only have one point then just move the center
485 if (d->id1 == touchPoint1.id())
486 sceneCenter = d->sceneLastCenter + touchPoint1.scenePosition() - d->lastPoint1;
487 else
488 sceneCenter = d->sceneLastCenter + touchPoint2.scenePosition() - d->lastPoint2;
489 angle = d->pinchLastAngle;
490 }
491 d->id1 = touchPoint1.id();
492 if (angle > 180)
493 angle -= 360;
494 qCDebug(lcPA, "pinch \u2316 %.1lf,%.1lf \u21e4%.1lf\u21e5 \u2220 %.1lf",
495 sceneCenter.x(), sceneCenter.y(), dist, angle);
496 if (!d->inPinch || d->initPinch) {
497 if (d->touchPoints.size() >= 2) {
498 if (d->initPinch) {
499 if (!d->inPinch)
500 d->pinchStartDist = dist;
501 d->initPinch = false;
502 }
503 d->sceneStartCenter = sceneCenter;
504 d->sceneLastCenter = sceneCenter;
505 d->pinchStartCenter = mapFromScene(sceneCenter);
506 d->pinchStartAngle = angle;
507 d->pinchLastScale = 1.0;
508 d->pinchLastAngle = angle;
509 d->pinchRotation = 0.0;
510 d->lastPoint1 = p1;
511 d->lastPoint2 = p2;
512 if (qAbs(dist - d->pinchStartDist) >= dragThreshold ||
513 (pinch()->axis() != QQuickPinch::NoDrag &&
514 (qAbs(p1.x()-d->sceneStartPoint1.x()) >= dragThreshold
515 || qAbs(p1.y()-d->sceneStartPoint1.y()) >= dragThreshold
516 || qAbs(p2.x()-d->sceneStartPoint2.x()) >= dragThreshold
517 || qAbs(p2.y()-d->sceneStartPoint2.y()) >= dragThreshold))) {
518 QQuickPinchEvent pe(d->pinchStartCenter, 1.0, angle, 0.0);
519 d->pinchStartDist = dist;
520 pe.setStartCenter(d->pinchStartCenter);
521 pe.setPreviousCenter(d->pinchStartCenter);
522 pe.setPreviousAngle(d->pinchLastAngle);
523 pe.setPreviousScale(d->pinchLastScale);
524 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
525 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
526 pe.setPoint1(mapFromScene(d->lastPoint1));
527 pe.setPoint2(mapFromScene(d->lastPoint2));
528 pe.setPointCount(d->touchPoints.size());
529 emit pinchStarted(&pe);
530 if (pe.accepted()) {
531 d->inPinch = true;
532 event->setExclusiveGrabber(touchPoint1, this);
533 event->setExclusiveGrabber(touchPoint2, this);
534 setKeepTouchGrab(true);
535 // So that PinchArea works in PathView, grab mouse events too.
536 // We should be able to remove these setKeepMouseGrab calls when QTBUG-105567 is fixed.
537 setKeepMouseGrab(true);
538 d->inPinch = true;
539 if (d->pinch && d->pinch->target()) {
540 auto targetParent = pinch()->target()->parentItem();
541 d->pinchStartPos = targetParent ?
542 targetParent->mapToScene(pinch()->target()->position()) :
543 pinch()->target()->position();
544 d->pinchStartScale = d->pinch->target()->scale();
545 d->pinchStartRotation = d->pinch->target()->rotation();
546 d->pinch->setActive(true);
547 }
548 } else {
549 d->pinchRejected = true;
550 }
551 }
552 }
553 } else if (d->pinchStartDist > 0) {
554 qreal scale = dist ? dist / d->pinchStartDist : d->pinchLastScale;
555 qreal da = d->pinchLastAngle - angle;
556 if (da > 180)
557 da -= 360;
558 else if (da < -180)
559 da += 360;
560 d->pinchRotation += da;
561 QPointF pinchCenter = mapFromScene(sceneCenter);
562 QQuickPinchEvent pe(pinchCenter, scale, angle, d->pinchRotation);
563 pe.setStartCenter(d->pinchStartCenter);
564 pe.setPreviousCenter(mapFromScene(d->sceneLastCenter));
565 pe.setPreviousAngle(d->pinchLastAngle);
566 pe.setPreviousScale(d->pinchLastScale);
567 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
568 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
569 pe.setPoint1(touchPoint1.position());
570 pe.setPoint2(touchPoint2.position());
571 pe.setPointCount(d->touchPoints.size());
572 d->pinchLastScale = scale;
573 d->sceneLastCenter = sceneCenter;
574 d->pinchLastAngle = angle;
575 d->lastPoint1 = touchPoint1.scenePosition();
576 d->lastPoint2 = touchPoint2.scenePosition();
577 emit pinchUpdated(&pe);
578 updatePinchTarget();
579 }
580 }
581}
582
583void QQuickPinchArea::updatePinchTarget()
584{
585 Q_D(QQuickPinchArea);
586 if (d->pinch && d->pinch->target()) {
587 qreal s = d->pinchStartScale * d->pinchLastScale;
588 s = qMin(qMax(pinch()->minimumScale(),s), pinch()->maximumScale());
589 pinch()->target()->setScale(s);
590 QPointF pos = d->sceneLastCenter - d->sceneStartCenter + d->pinchStartPos;
591 if (auto targetParent = pinch()->target()->parentItem())
592 pos = targetParent->mapFromScene(pos);
593
594 if (pinch()->axis() & QQuickPinch::XAxis) {
595 qreal x = pos.x();
596 if (x < pinch()->xmin())
597 x = pinch()->xmin();
598 else if (x > pinch()->xmax())
599 x = pinch()->xmax();
600 pinch()->target()->setX(x);
601 }
602 if (pinch()->axis() & QQuickPinch::YAxis) {
603 qreal y = pos.y();
604 if (y < pinch()->ymin())
605 y = pinch()->ymin();
606 else if (y > pinch()->ymax())
607 y = pinch()->ymax();
608 pinch()->target()->setY(y);
609 }
610 if (d->pinchStartRotation >= pinch()->minimumRotation()
611 && d->pinchStartRotation <= pinch()->maximumRotation()) {
612 qreal r = d->pinchRotation + d->pinchStartRotation;
613 r = qMin(qMax(pinch()->minimumRotation(),r), pinch()->maximumRotation());
614 pinch()->target()->setRotation(r);
615 }
616 }
617}
618
629{
630 Q_D(QQuickPinchArea);
631 if (!d->enabled || !isVisible())
633 auto *te = static_cast<QTouchEvent*>(e);
634 switch (e->type()) {
636 clearPinch(te);
638 case QEvent::TouchUpdate: {
639 const auto &points = te->points();
640 d->touchPoints.clear();
641 for (auto &tp : points) {
642 if (tp.state() != QEventPoint::State::Released)
643 d->touchPoints << tp;
644 }
645 updatePinch(te, true);
646 }
647 e->setAccepted(d->inPinch);
648 return d->inPinch;
649 case QEvent::TouchEnd:
650 clearPinch(te);
651 break;
652 default:
653 break;
654 }
655
657}
658
659void QQuickPinchArea::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
660{
661 QQuickItem::geometryChange(newGeometry, oldGeometry);
662}
663
668
670{
671 Q_D(QQuickPinchArea);
672 if (!d->enabled || !isVisible())
673 return QQuickItem::event(event);
674
675 switch (event->type()) {
676#if QT_CONFIG(gestures)
678 QNativeGestureEvent *gesture = static_cast<QNativeGestureEvent *>(event);
679 switch (gesture->gestureType()) {
681 clearPinch(nullptr); // probably not necessary; JIC
682 d->pinchStartCenter = gesture->position();
683 d->pinchStartAngle = 0.0;
684 d->pinchStartRotation = 0.0;
685 d->pinchRotation = 0.0;
686 d->pinchStartScale = 1.0;
687 d->pinchLastAngle = 0.0;
688 d->pinchLastScale = 1.0;
689 d->sceneStartPoint1 = gesture->scenePosition();
690 d->sceneStartPoint2 = gesture->scenePosition(); // TODO we never really know
691 d->lastPoint1 = gesture->scenePosition();
692 d->lastPoint2 = gesture->scenePosition(); // TODO we never really know
693 if (d->pinch && d->pinch->target()) {
694 d->pinchStartPos = d->pinch->target()->position();
695 d->pinchStartScale = d->pinch->target()->scale();
696 d->pinchStartRotation = d->pinch->target()->rotation();
697 d->pinch->setActive(true);
698 }
699 break;
701 clearPinch(nullptr);
702 break;
704 if (d->pinchRejected)
705 break;
706 qreal scale = d->pinchLastScale * (1.0 + gesture->value());
707 QQuickPinchEvent pe(d->pinchStartCenter, scale, d->pinchLastAngle, 0.0);
708 pe.setStartCenter(d->pinchStartCenter);
709 pe.setPreviousCenter(d->pinchStartCenter);
710 pe.setPreviousAngle(d->pinchLastAngle);
711 pe.setPreviousScale(d->pinchLastScale);
712 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
713 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
714 pe.setPoint1(mapFromScene(d->lastPoint1));
715 pe.setPoint2(mapFromScene(d->lastPoint2));
716 pe.setPointCount(2);
717 d->pinchLastScale = scale;
718 if (d->inPinch)
719 emit pinchUpdated(&pe);
720 else
721 emit pinchStarted(&pe);
722 d->inPinch = true;
723 if (pe.accepted())
724 updatePinchTarget();
725 else
726 d->pinchRejected = true;
727 } break;
729 if (gesture->value() > 0.0 && d->pinch && d->pinch->target()) {
730 d->pinchStartPos = pinch()->target()->position();
731 d->pinchStartCenter = mapToItem(pinch()->target()->parentItem(), pinch()->target()->boundingRect().center());
732 d->pinchStartScale = d->pinch->target()->scale();
733 d->pinchStartRotation = d->pinch->target()->rotation();
734 d->pinchLastScale = d->pinchStartScale = d->pinch->target()->scale();
735 d->pinchLastAngle = d->pinchStartRotation = d->pinch->target()->rotation();
736 }
737 QQuickPinchEvent pe(gesture->position(), gesture->value(), d->pinchLastAngle, 0.0);
738 pe.setStartCenter(gesture->position());
739 pe.setPreviousCenter(d->pinchStartCenter);
740 pe.setPreviousAngle(d->pinchLastAngle);
741 pe.setPreviousScale(d->pinchLastScale);
742 pe.setStartPoint1(gesture->position());
743 pe.setStartPoint2(gesture->position());
744 pe.setPoint1(mapFromScene(gesture->scenePosition()));
745 pe.setPoint2(mapFromScene(gesture->scenePosition()));
746 pe.setPointCount(2);
747 emit smartZoom(&pe);
748 } break;
750 if (d->pinchRejected)
751 break;
752 qreal angle = d->pinchLastAngle + gesture->value();
753 QQuickPinchEvent pe(d->pinchStartCenter, d->pinchLastScale, angle, 0.0);
754 pe.setStartCenter(d->pinchStartCenter);
755 pe.setPreviousCenter(d->pinchStartCenter);
756 pe.setPreviousAngle(d->pinchLastAngle);
757 pe.setPreviousScale(d->pinchLastScale);
758 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
759 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
760 pe.setPoint1(mapFromScene(d->lastPoint1));
761 pe.setPoint2(mapFromScene(d->lastPoint2));
762 pe.setPointCount(2);
763 d->pinchLastAngle = angle;
764 if (d->inPinch)
765 emit pinchUpdated(&pe);
766 else
767 emit pinchStarted(&pe);
768 d->inPinch = true;
769 d->pinchRotation = angle;
770 if (pe.accepted())
771 updatePinchTarget();
772 else
773 d->pinchRejected = true;
774 } break;
775 default:
776 return QQuickItem::event(event);
777 }
778 } break;
779#endif // gestures
780 case QEvent::Wheel:
781 event->ignore();
782 return false;
783 default:
784 return QQuickItem::event(event);
785 }
786
787 return true;
788}
789
791{
792 Q_D(QQuickPinchArea);
793 if (!d->pinch)
794 d->pinch = new QQuickPinch;
795 return d->pinch;
796}
797
799
800#include "moc_qquickpincharea_p.cpp"
bool m_active
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
\inmodule QtCore
Definition qcoreevent.h:45
virtual void setAccepted(bool accepted)
Definition qcoreevent.h:307
@ NativeGesture
Definition qcoreevent.h:246
@ TouchCancel
Definition qcoreevent.h:264
@ TouchUpdate
Definition qcoreevent.h:242
@ TouchBegin
Definition qcoreevent.h:241
Type type() const
Returns the event type.
Definition qcoreevent.h:304
static QStyleHints * styleHints()
Returns the application's style hints.
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
Definition qline.h:192
qreal angle() const
Definition qline.cpp:564
The QNativeGestureEvent class contains parameters that describe a gesture event. \inmodule QtGui.
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
bool event(QEvent *) override
\reimp
void setKeepTouchGrab(bool)
Sets whether the touch points grabbed by this item should remain exclusively with this item.
void setScale(qreal)
void setRotation(qreal)
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
Q_INVOKABLE QPointF mapToItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within item's coordinat...
void setAcceptHoverEvents(bool enabled)
If enabled is true, this sets the item to accept hover events; otherwise, hover events are not accept...
QPointF mapFromScene(const QPointF &point) const
Maps the given point in the scene's coordinate system to the equivalent point within this item's coor...
void setAcceptTouchEvents(bool accept)
If enabled is true, this sets the item to accept touch events; otherwise, touch events are not accept...
bool isVisible() const
virtual QRectF boundingRect() const
Returns the extents of the item in its own coordinate system: a rectangle from {0,...
QQuickItem * parentItem() const
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
QPointF position() const
void setKeepMouseGrab(bool)
Sets whether the mouse input should remain exclusively with this item.
virtual void touchEvent(QTouchEvent *event)
This event handler can be reimplemented in a subclass to receive touch events for an item.
virtual bool childMouseEventFilter(QQuickItem *, QEvent *)
Reimplement this method to filter the pointer events that are received by this item's children.
virtual QRectF clipRect() const
Returns the rectangular area within this item that is currently visible in \l viewportItem(),...
qreal scale
\qmlproperty real QtQuick::Item::scale This property holds the scale factor for this item.
Definition qquickitem.h:107
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:144
void setX(qreal)
void setY(qreal)
QQuickPinch * pinch
bool event(QEvent *) override
\reimp
bool isEnabled() const
\qmlproperty bool QtQuick::PinchArea::enabled This property holds whether the item accepts pinch gest...
bool childMouseEventFilter(QQuickItem *i, QEvent *e) override
void pinchFinished(QQuickPinchEvent *pinch)
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void pinchUpdated(QQuickPinchEvent *pinch)
void enabledChanged()
QQuickPinchArea(QQuickItem *parent=nullptr)
\qmltype PinchArea \instantiates QQuickPinchArea \inqmlmodule QtQuick\inherits Item
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
void pinchStarted(QQuickPinchEvent *pinch)
void touchEvent(QTouchEvent *event) override
This event handler can be reimplemented in a subclass to receive touch events for an item.
qreal ymin() const
qreal xmin() const
qreal xmax() const
qreal ymax() const
QQuickItem * target
\inmodule QtCore\reentrant
Definition qrect.h:484
bool contains(const QRectF &r) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:1993
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
QPixmap p2
QPixmap p1
[0]
Combined button and popup list for selecting options.
@ RotateNativeGesture
@ ZoomNativeGesture
@ BeginNativeGesture
@ EndNativeGesture
@ SmartZoomNativeGesture
#define Q_FALLTHROUGH()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
qfloat16 qSqrt(qfloat16 f)
Definition qfloat16.h:289
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLboolean r
[2]
GLfloat angle
GLenum target
GLint y
struct _cl_event * event
GLfixed GLfixed GLint GLint GLfixed points
GLdouble s
[6]
Definition qopenglext.h:235
GLenum GLenum GLenum GLenum GLenum scale
#define emit
#define PRIdQSIZETYPE
Definition qtypes.h:172
double qreal
Definition qtypes.h:187
std::uniform_real_distribution dist(1, 2.5)
[2]
\inmodule QtQuick
Definition qquickitem.h:159