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
qquickmultipointtoucharea.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 <QtQuick/qquickwindow.h>
6#include <private/qsgadaptationlayer_p.h>
7#include <private/qquickitem_p.h>
8#include <private/qquickwindow_p.h>
9#include <private/qguiapplication_p.h>
10#include <QtGui/private/qevent_p.h>
11#include <QtGui/private/qeventpoint_p.h>
12#include <QtGui/private/qpointingdevice_p.h>
13#include <QEvent>
14#include <QMouseEvent>
15#include <QDebug>
16#include <qpa/qplatformnativeinterface.h>
17
19
20DEFINE_BOOL_CONFIG_OPTION(qmlMptaVisualTouchDebugging, QML_VISUAL_TOUCH_DEBUGGING)
21
22
42void QQuickTouchPoint::setPointId(int id)
43{
44 if (_id == id)
45 return;
46 _id = id;
47 emit pointIdChanged();
48}
49
58{
59 bool xch = (_x != p.x());
60 bool ych = (_y != p.y());
61 if (!xch && !ych)
62 return;
63 _x = p.x();
64 _y = p.y();
65 if (xch)
66 emit xChanged();
67 if (ych)
68 emit yChanged();
69}
70
79{
80 if (_ellipseDiameters == d)
81 return;
82 _ellipseDiameters = d;
83 emit ellipseDiametersChanged();
84}
85
101{
102 if (_pressure == pressure)
103 return;
104 _pressure = pressure;
106}
107
121{
122 if (_rotation == r)
123 return;
124 _rotation = r;
125 emit rotationChanged();
126}
127
129{
130 if (_velocity == velocity)
131 return;
132 _velocity = velocity;
134}
135
147{
148 if (_area == area)
149 return;
150 _area = area;
152}
153
160{
161 if (_pressed == pressed)
162 return;
163 _pressed = pressed;
165}
166
175{
176 if (_startX == startX)
177 return;
178 _startX = startX;
180}
181
183{
184 if (_startY == startY)
185 return;
186 _startY = startY;
188}
189
197{
198 if (_previousX == previousX)
199 return;
200 _previousX = previousX;
202}
203
205{
206 if (_previousY == previousY)
207 return;
208 _previousY = previousY;
210}
211
220{
221 if (_sceneX == sceneX)
222 return;
223 _sceneX = sceneX;
225}
226
228{
229 if (_sceneY == sceneY)
230 return;
231 _sceneY = sceneY;
233}
234
249{
250 _uniqueId = id;
251 emit uniqueIdChanged();
252}
253
254
389// TODO Qt 7: remove the notes above about the signal touchPoints arguments
390
431 : QQuickItem(parent),
432 _minimumTouchPoints(0),
433 _maximumTouchPoints(INT_MAX),
434 _touchMouseDevice(nullptr),
435 _stealMouse(false),
436 _mouseEnabled(true)
437{
440 if (qmlMptaVisualTouchDebugging()) {
442 }
444#ifdef Q_OS_MACOS
445 setAcceptHoverEvents(true); // needed to enable touch events on mouse hover.
446#endif
447}
448
450{
452 for (QObject *obj : std::as_const(_touchPoints)) {
453 QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj);
454 if (!dtp->isQmlDefined())
455 delete dtp;
456 }
457}
458
477{
478 return _minimumTouchPoints;
479}
480
482{
483 if (_minimumTouchPoints == num)
484 return;
485 _minimumTouchPoints = num;
487}
488
490{
491 return _maximumTouchPoints;
492}
493
495{
496 if (_maximumTouchPoints == num)
497 return;
498 _maximumTouchPoints = num;
500}
501
512{
513 if (_mouseEnabled != arg) {
514 _mouseEnabled = arg;
515 if (_mouseTouchPoint && !arg)
516 _mouseTouchPoint = nullptr;
518 }
519}
520
522{
523 switch (event->type()) {
526 case QEvent::TouchEnd: {
527 //if e.g. a parent Flickable has the mouse grab, don't process the touch events
528 QQuickWindow *c = window();
529 QQuickItem *grabber = c ? c->mouseGrabberItem() : nullptr;
530 if (grabber && grabber != this && grabber->keepMouseGrab() && grabber->isEnabled()) {
531 QQuickItem *item = this;
532 while ((item = item->parentItem())) {
533 if (item == grabber)
534 return;
535 }
536 }
538 if (event->type() == QEvent::TouchEnd)
539 ungrab(true);
540 break;
541 }
543 ungrab();
544 break;
545 default:
547 break;
548 }
549}
550
552{
553 _stealMouse = true;
554
555 grabMouse();
556 setKeepMouseGrab(true);
557
559 for (auto it = _touchPoints.keyBegin(), end = _touchPoints.keyEnd(); it != end; ++it) {
560 if (*it != -1) // -1 might be the mouse-point, but we already grabbed the mouse above.
561 if (auto pt = devPriv->queryPointById(*it))
562 pt->exclusiveGrabber = this;
563 }
564 setKeepTouchGrab(true);
565}
566
568{
569 bool ended = false;
570 bool moved = false;
571 bool started = false;
572
574 QList<QEventPoint> touchPoints;
575 bool touchPointsFromEvent = false;
576 QPointingDevice *dev = nullptr;
577
578 switch (event->type()) {
581 case QEvent::TouchEnd: {
582 QTouchEvent* te = static_cast<QTouchEvent*>(event);
583 touchPoints = te->points();
584 touchPointsFromEvent = true;
585 dev = const_cast<QPointingDevice *>(te->pointingDevice());
586 break;
587 }
589 auto da = QQuickItemPrivate::get(this)->deliveryAgentPrivate();
590 _mouseQpaTouchPoint = QEventPoint(da->touchMouseId);
591 _touchMouseDevice = da->touchMouseDevice;
593 }
596 QMouseEvent *me = static_cast<QMouseEvent*>(event);
597 _mouseQpaTouchPoint = me->points().first();
598 dev = const_cast<QPointingDevice *>(me->pointingDevice());
599 if (event->type() == QEvent::MouseButtonPress) {
600 addTouchPoint(me);
601 started = true;
602 }
603 touchPoints << _mouseQpaTouchPoint;
604 break;
605 }
606 default:
607 qWarning("updateTouchData: unhandled event type %d", event->type());
608 break;
609 }
610
611 int numTouchPoints = touchPoints.size();
612 //always remove released touches, and make sure we handle all releases before adds.
613 for (const QEventPoint &p : std::as_const(touchPoints)) {
614 QEventPoint::State touchPointState = p.state();
615 int id = p.id();
616 if (touchPointState & QEventPoint::State::Released) {
617 QQuickTouchPoint* dtp = static_cast<QQuickTouchPoint*>(_touchPoints.value(id));
618 if (!dtp)
619 continue;
620 updateTouchPoint(dtp, &p);
621 dtp->setPressed(false);
622 _releasedTouchPoints.append(dtp);
623 _touchPoints.remove(id);
624 ended = true;
625 }
626 }
627 if (numTouchPoints >= _minimumTouchPoints && numTouchPoints <= _maximumTouchPoints) {
628 for (QEventPoint &p : touchPoints) {
629 QPointF oldPos = p.position();
630 auto transformBack = qScopeGuard([&] { QMutableEventPoint::setPosition(p, oldPos); });
631 if (touchPointsFromEvent && remap == RemapEventPoints::ToLocal)
632 QMutableEventPoint::setPosition(p, mapFromScene(p.scenePosition()));
633 QEventPoint::State touchPointState = p.state();
634 int id = p.id();
635 if (touchPointState & QEventPoint::State::Released) {
636 //handled above
637 } else if (!_touchPoints.contains(id)) { //could be pressed, moved, or stationary
638 // (we may have just obtained enough points to start tracking them -- in that case moved or stationary count as newly pressed)
640 started = true;
641 } else if ((touchPointState & QEventPoint::State::Updated) ||
642 (touchPointState & QEventPoint::State::Stationary)) {
643 // React to a stationary point as if the point moved. (QTBUG-77142)
644 QQuickTouchPoint* dtp = static_cast<QQuickTouchPoint*>(_touchPoints.value(id));
645 Q_ASSERT(dtp);
646 _movedTouchPoints.append(dtp);
647 updateTouchPoint(dtp,&p);
648 moved = true;
649 } else {
650 QQuickTouchPoint* dtp = static_cast<QQuickTouchPoint*>(_touchPoints.value(id));
651 Q_ASSERT(dtp);
652 updateTouchPoint(dtp,&p);
653 }
654 }
655
656 //see if we should be grabbing the gesture
657 if (!_stealMouse /* !ignoring gesture*/) {
658 bool offerGrab = false;
659 const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
660 for (const QEventPoint &p : std::as_const(touchPoints)) {
661 if (p.state() == QEventPoint::State::Released)
662 continue;
663 const QPointF &currentPos = p.scenePosition();
664 const QPointF &startPos = p.scenePressPosition();
665 if (qAbs(currentPos.x() - startPos.x()) > dragThreshold)
666 offerGrab = true;
667 else if (qAbs(currentPos.y() - startPos.y()) > dragThreshold)
668 offerGrab = true;
669 if (offerGrab)
670 break;
671 }
672
673 if (offerGrab) {
675 event._touchPoints = _touchPoints.values();
677 if (event.wantsGrab() && dev)
678 grabGesture(dev);
679 }
680 }
681
682 if (ended)
683 emit released(_releasedTouchPoints);
684 if (moved)
685 emit updated(_movedTouchPoints);
686 if (started && !_pressedTouchPoints.isEmpty())
687 emit pressed(_pressedTouchPoints);
688 if (ended || moved || started) emit touchUpdated(_touchPoints.values());
689 }
690}
691
693{
694 for (QObject *obj : std::as_const(_releasedTouchPoints)) {
695 QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj);
696 if (!dtp->isQmlDefined()) {
697 _touchPoints.remove(dtp->pointId());
698 delete dtp;
699 } else {
700 dtp->setInUse(false);
701 }
702 }
703 _releasedTouchPoints.clear();
704 _pressedTouchPoints.clear();
705 _movedTouchPoints.clear();
706}
707
709{
710 QQuickTouchPoint *dtp = nullptr;
711 for (QQuickTouchPoint* tp : std::as_const(_touchPrototypes)) {
712 if (!tp->inUse()) {
713 tp->setInUse(true);
714 dtp = tp;
715 break;
716 }
717 }
718
719 if (dtp == nullptr)
720 dtp = new QQuickTouchPoint(false);
721 dtp->setPointId(p->id());
722 updateTouchPoint(dtp,p);
723 dtp->setPressed(true);
724 _touchPoints.insert(p->id(),dtp);
725 _pressedTouchPoints.append(dtp);
726}
727
729{
730 QQuickTouchPoint *dtp = nullptr;
731 for (QQuickTouchPoint *tp : std::as_const(_touchPrototypes)) {
732 if (!tp->inUse()) {
733 tp->setInUse(true);
734 dtp = tp;
735 break;
736 } else if (_mouseTouchPoint == tp) {
737 return; // do not allow more than one touchpoint to react to the mouse (QTBUG-83662)
738 }
739 }
740
741 if (dtp == nullptr)
742 dtp = new QQuickTouchPoint(false);
743 updateTouchPoint(dtp, e);
744 dtp->setPressed(true);
745 _touchPoints.insert(_mouseQpaTouchPoint.id(), dtp);
746 _pressedTouchPoints.append(dtp);
747 _mouseTouchPoint = dtp;
748}
749
750#ifdef Q_OS_MACOS
752{
753 setTouchEventsEnabled(isEnabled());
755}
756
758{
759 setTouchEventsEnabled(false);
761}
762
763void QQuickMultiPointTouchArea::setTouchEventsEnabled(bool enable)
764{
765 // Resolve function for enabling touch events from the (cocoa) platform plugin.
766 typedef void (*RegisterTouchWindowFunction)(QWindow *, bool);
767 RegisterTouchWindowFunction registerTouchWindow = reinterpret_cast<RegisterTouchWindowFunction>(
768 QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow"));
769 if (!registerTouchWindow)
770 return; // Not necessarily an error, Qt might be using a different platform plugin.
771
772 registerTouchWindow(window(), enable);
773}
774
775void QQuickMultiPointTouchArea::itemChange(ItemChange change, const ItemChangeData &data)
776{
777 if (change == ItemEnabledHasChanged)
778 setAcceptHoverEvents(data.boolValue);
780}
781#endif // Q_OS_MACOS
782
784{
785 int id = _touchPrototypes.size();
786 prototype->setPointId(id);
787 _touchPrototypes.insert(id, prototype);
788}
789
791{
792 //TODO: if !qmlDefined, could bypass setters.
793 // also, should only emit signals after all values have been set
794 dtp->setUniqueId(p->uniqueId());
795 dtp->setPosition(p->position());
796 dtp->setEllipseDiameters(p->ellipseDiameters());
797 dtp->setPressure(p->pressure());
798 dtp->setRotation(p->rotation());
799 dtp->setVelocity(p->velocity());
800 QRectF area(QPointF(), p->ellipseDiameters());
801 area.moveCenter(p->position());
802 dtp->setArea(area);
803 dtp->setStartX(p->pressPosition().x());
804 dtp->setStartY(p->pressPosition().y());
805 dtp->setPreviousX(p->lastPosition().x());
806 dtp->setPreviousY(p->lastPosition().y());
807 dtp->setSceneX(p->scenePosition().x());
808 dtp->setSceneY(p->scenePosition().y());
809}
810
812{
813 dtp->setPreviousX(dtp->x());
814 dtp->setPreviousY(dtp->y());
815 dtp->setPosition(e->position());
816 if (e->type() == QEvent::MouseButtonPress) {
817 dtp->setStartX(e->position().x());
818 dtp->setStartY(e->position().y());
819 }
820 dtp->setSceneX(e->scenePosition().x());
821 dtp->setSceneY(e->scenePosition().y());
822}
823
825{
826 if (!isEnabled() || !_mouseEnabled || event->button() != Qt::LeftButton) {
828 return;
829 }
830
831 _stealMouse = false;
832 setKeepMouseGrab(false);
833 event->setAccepted(true);
834 _mousePos = event->position();
836 return;
837
838 if (_touchPoints.size() >= _minimumTouchPoints - 1 && _touchPoints.size() < _maximumTouchPoints) {
840 }
841}
842
844{
845 if (!isEnabled() || !_mouseEnabled) {
847 return;
848 }
849
851 return;
852
853 _movedTouchPoints.clear();
855}
856
858{
859 _stealMouse = false;
860 if (!isEnabled() || !_mouseEnabled) {
862 return;
863 }
864
866 return;
867
868 if (_mouseTouchPoint) {
870 _mouseTouchPoint->setInUse(false);
871 _releasedTouchPoints.removeAll(_mouseTouchPoint);
872 _mouseTouchPoint = nullptr;
873 }
874
875 setKeepMouseGrab(false);
876}
877
878void QQuickMultiPointTouchArea::ungrab(bool normalRelease)
879{
880 _stealMouse = false;
881 setKeepMouseGrab(false);
882 setKeepTouchGrab(false);
883 if (!normalRelease)
885
886 if (_touchPoints.size()) {
887 for (QObject *obj : std::as_const(_touchPoints))
888 static_cast<QQuickTouchPoint*>(obj)->setPressed(false);
889 if (!normalRelease)
890 emit canceled(_touchPoints.values());
892 for (QObject *obj : std::as_const(_touchPoints)) {
893 QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj);
894 if (!dtp->isQmlDefined())
895 delete dtp;
896 else
897 dtp->setInUse(false);
898 }
899 _touchPoints.clear();
900 emit touchUpdated(QList<QObject*>());
901 }
902}
903
905{
906 ungrab();
907}
908
910{
911 ungrab();
912}
913
915{
916 const QPointF localPos = mapFromScene(event->scenePosition());
917
918 QQuickWindow *c = window();
919 QQuickItem *grabber = c ? c->mouseGrabberItem() : nullptr;
920 bool stealThisEvent = _stealMouse;
921 if ((stealThisEvent || contains(localPos)) && (!grabber || !grabber->keepMouseGrab())) {
922 QMutableSinglePointEvent mouseEvent(*event);
923 const auto oldPosition = mouseEvent.position();
924 QMutableEventPoint::setPosition(mouseEvent.point(0), localPos);
926 mouseEvent.setAccepted(false);
927 QMouseEvent *pmouseEvent = static_cast<QMouseEvent *>(static_cast<QSinglePointEvent *>(&mouseEvent));
928
929 switch (mouseEvent.type()) {
931 mouseMoveEvent(pmouseEvent);
932 break;
934 mousePressEvent(pmouseEvent);
935 break;
937 mouseReleaseEvent(pmouseEvent);
938 break;
939 default:
940 break;
941 }
942 grabber = c ? c->mouseGrabberItem() : nullptr;
943 if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
944 grabMouse();
945
946 QMutableEventPoint::setPosition(mouseEvent.point(0), oldPosition);
947 return stealThisEvent;
948 }
949 if (event->type() == QEvent::MouseButtonRelease) {
950 _stealMouse = false;
951 if (c && c->mouseGrabberItem() == this)
952 ungrabMouse();
953 setKeepMouseGrab(false);
954 }
955 return false;
956}
957
959{
960 if (!isEnabled() || !isVisible())
962 switch (event->type()) {
964 auto da = QQuickItemPrivate::get(this)->deliveryAgentPrivate();
965 // If we already got a chance to filter the touchpoint that generated this synth-mouse-press,
966 // and chose not to filter it, ignore it now, too.
967 if (static_cast<QMouseEvent *>(event)->source() == Qt::MouseEventSynthesizedByQt &&
968 _lastFilterableTouchPointIds.contains(da->touchMouseId))
969 return false;
970 } Q_FALLTHROUGH();
973 return sendMouseEvent(static_cast<QMouseEvent *>(event));
975 _lastFilterableTouchPointIds.clear();
978 for (const auto &tp : static_cast<QTouchEvent*>(event)->points()) {
979 if (tp.state() == QEventPoint::State::Pressed)
980 _lastFilterableTouchPointIds << tp.id();
981 }
982 if (!shouldFilter(event))
983 return false;
985 return _stealMouse;
986 case QEvent::TouchEnd: {
987 if (!shouldFilter(event))
988 return false;
990 ungrab(true);
991 }
992 break;
993 default:
994 break;
995 }
997}
998
1000{
1001 QQuickWindow *c = window();
1002 QQuickItem *grabber = c ? c->mouseGrabberItem() : nullptr;
1003 bool disabledItem = grabber && !grabber->isEnabled();
1004 bool stealThisEvent = _stealMouse;
1005 bool containsPoint = false;
1006 if (!stealThisEvent) {
1007 switch (event->type()) {
1009 case QEvent::MouseMove:
1011 QMouseEvent *me = static_cast<QMouseEvent*>(event);
1012 containsPoint = contains(mapFromScene(me->scenePosition()));
1013 }
1014 break;
1015 case QEvent::TouchBegin:
1017 case QEvent::TouchEnd: {
1018 QTouchEvent *te = static_cast<QTouchEvent*>(event);
1019 for (const QEventPoint &point : te->points()) {
1020 if (contains(mapFromScene(point.scenePosition()))) {
1021 containsPoint = true;
1022 break;
1023 }
1024 }
1025 }
1026 break;
1027 default:
1028 break;
1029 }
1030 }
1031 if ((stealThisEvent || containsPoint) && (!grabber || !grabber->keepMouseGrab() || disabledItem)) {
1032 return true;
1033 }
1034 ungrab();
1035 return false;
1036}
1037
1039{
1040 Q_UNUSED(data);
1041
1042 if (!qmlMptaVisualTouchDebugging())
1043 return nullptr;
1044
1045 QSGInternalRectangleNode *rectangle = static_cast<QSGInternalRectangleNode *>(oldNode);
1046 if (!rectangle) rectangle = QQuickItemPrivate::get(this)->sceneGraphContext()->createInternalRectangleNode();
1047
1048 rectangle->setRect(QRectF(0, 0, width(), height()));
1049 rectangle->setColor(QColor(255, 0, 0, 50));
1050 rectangle->update();
1051 return rectangle;
1052}
1053
1055
1056#include "moc_qquickmultipointtoucharea_p.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
int id
the ID number of this event point.
Definition qeventpoint.h:24
State
Specifies the state of this event point.
Definition qeventpoint.h:48
\inmodule QtCore
Definition qcoreevent.h:45
@ MouseMove
Definition qcoreevent.h:63
@ TouchCancel
Definition qcoreevent.h:264
@ MouseButtonPress
Definition qcoreevent.h:60
@ TouchUpdate
Definition qcoreevent.h:242
@ TouchBegin
Definition qcoreevent.h:241
@ MouseButtonRelease
Definition qcoreevent.h:61
Type type() const
Returns the event type.
Definition qcoreevent.h:304
QGraphicsItem * parentItem() const
Returns a pointer to this item's parent item.
static QPlatformNativeInterface * platformNativeInterface()
static QStyleHints * styleHints()
Returns the application's style hints.
\inmodule QtGui
Definition qevent.h:246
bool isEmpty() const noexcept
Definition qlist.h:401
T & first()
Definition qlist.h:645
qsizetype removeAll(const AT &t)
Definition qlist.h:592
void append(parameter_type t)
Definition qlist.h:458
void clear()
Definition qlist.h:434
iterator insert(const Key &key, const T &value)
Definition qmap.h:688
T value(const Key &key, const T &defaultValue=T()) const
Definition qmap.h:357
bool contains(const Key &key) const
Definition qmap.h:341
QList< T > values() const
Definition qmap.h:397
size_type remove(const Key &key)
Definition qmap.h:300
void clear()
Definition qmap.h:289
size_type size() const
Definition qmap.h:267
key_iterator keyBegin() const
Definition qmap.h:606
key_iterator keyEnd() const
Definition qmap.h:607
\inmodule QtGui
Definition qevent.h:196
void setSource(Qt::MouseEventSource s)
Definition qevent_p.h:61
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:343
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:348
const QPointingDevice * pointingDevice() const
Returns the source device from which this event originates.
Definition qevent.cpp:330
QEventPoint & point(qsizetype i)
Returns a QEventPoint reference for the point at index i.
Definition qevent.cpp:240
virtual void setAccepted(bool accepted) override
\reimp
Definition qevent.cpp:318
const QList< QEventPoint > & points() const
Returns a list of points in this pointer event.
Definition qevent.h:87
static QPointingDevicePrivate * get(QPointingDevice *q)
QPointingDeviceUniqueId identifies a unique object, such as a tagged token or stylus,...
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
void setFiltersChildMouseEvents(bool filter)
Sets whether pointer events intended for this item's children should be filtered through this item.
virtual void mouseReleaseEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse release events for an item.
virtual void hoverEnterEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
void setKeepTouchGrab(bool)
Sets whether the touch points grabbed by this item should remain exclusively with this item.
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
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 ungrabTouchPoints()
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 Q_INVOKABLE bool contains(const QPointF &point) const
\qmlmethod bool QtQuick::Item::contains(point point)
void setAcceptedMouseButtons(Qt::MouseButtons buttons)
Sets the mouse buttons accepted by this item to buttons.
void ungrabMouse()
QQuickWindow * window() const
Returns the window in which this item is rendered.
virtual void mousePressEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
qreal width
This property holds the width of this item.
Definition qquickitem.h:75
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
bool isEnabled() const
void setKeepMouseGrab(bool)
Sets whether the mouse input should remain exclusively with this item.
void grabMouse()
virtual void touchEvent(QTouchEvent *event)
This event handler can be reimplemented in a subclass to receive touch events for an item.
qreal height
This property holds the height of this item.
Definition qquickitem.h:76
virtual bool childMouseEventFilter(QQuickItem *, QEvent *)
Reimplement this method to filter the pointer events that are received by this item's children.
@ ItemEnabledHasChanged
Definition qquickitem.h:155
virtual void hoverLeaveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
virtual void mouseMoveEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse move events for an item.
void canceled(const QList< QObject * > &points)
void updateTouchData(QEvent *, RemapEventPoints remap=RemapEventPoints::No)
void mouseReleaseEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse release events for an item.
QQuickMultiPointTouchArea(QQuickItem *parent=nullptr)
\qmltype GestureEvent \instantiates QQuickGrabGestureEvent \inqmlmodule QtQuick
void setMouseEnabled(bool arg)
\qmlproperty bool QtQuick::MultiPointTouchArea::mouseEnabled
void addTouchPrototype(QQuickTouchPoint *prototype)
bool childMouseEventFilter(QQuickItem *receiver, QEvent *event) override
Reimplement this method to filter the pointer events that are received by this item's children.
void touchUngrabEvent() override
This event handler can be reimplemented in a subclass to be notified when a touch ungrab event has oc...
void mouseMoveEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse move events for an item.
void touchEvent(QTouchEvent *) override
This event handler can be reimplemented in a subclass to receive touch events for an item.
void gestureStarted(QQuickGrabGestureEvent *gesture)
void addTouchPoint(const QEventPoint *p)
void mouseUngrabEvent() override
This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has oc...
QQmlListProperty< QQuickTouchPoint > touchPoints
bool sendMouseEvent(QMouseEvent *event)
void mousePressEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
void updated(const QList< QObject * > &points)
void released(const QList< QObject * > &points)
void updateTouchPoint(QQuickTouchPoint *, const QEventPoint *)
void grabGesture(QPointingDevice *dev)
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
void pressed(const QList< QObject * > &points)
void touchUpdated(const QList< QObject * > &points)
void setArea(const QRectF &area)
void setSceneX(qreal sceneX)
\qmlproperty real QtQuick::TouchPoint::sceneX \qmlproperty real QtQuick::TouchPoint::sceneY
void pressureChanged()
void setPressed(bool pressed)
\qmlproperty bool QtQuick::TouchPoint::pressed
void previousYChanged()
void setEllipseDiameters(const QSizeF &d)
\qmlproperty size QtQuick::TouchPoint::ellipseDiameters
void setUniqueId(const QPointingDeviceUniqueId &id)
\qmlproperty pointingDeviceUniqueId QtQuick::TouchPoint::uniqueId
void setPressure(qreal pressure)
\qmlproperty real QtQuick::TouchPoint::pressure \qmlproperty vector2d QtQuick::TouchPoint::velocity
void setStartX(qreal startX)
\qmlproperty real QtQuick::TouchPoint::startX \qmlproperty real QtQuick::TouchPoint::startY
void setRotation(qreal r)
\qmlproperty real QtQuick::TouchPoint::rotation
void setPreviousY(qreal previousY)
void velocityChanged()
void setVelocity(const QVector2D &velocity)
void setPointId(int id)
\qmltype TouchPoint \instantiates QQuickTouchPoint \inqmlmodule QtQuick
void setPosition(QPointF pos)
\qmlproperty real QtQuick::TouchPoint::x \qmlproperty real QtQuick::TouchPoint::y
void setPreviousX(qreal previousX)
\qmlproperty real QtQuick::TouchPoint::previousX \qmlproperty real QtQuick::TouchPoint::previousY
void previousXChanged()
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
Definition qrect.h:484
virtual void setRect(const QRectF &rect)=0
virtual void update()=0
virtual void setColor(const QColor &color)=0
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
A base class for pointer events containing a single point, such as mouse events.
Definition qevent.h:109
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
Definition qevent.h:119
QPointF scenePosition() const
Returns the position of the point in this event, relative to the window or scene.
Definition qevent.h:121
\inmodule QtCore
Definition qsize.h:208
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
\inmodule QtGui
Definition qwindow.h:63
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ LeftButton
Definition qnamespace.h:58
@ MouseEventSynthesizedByQt
@ MouseEventNotSynthesized
#define Q_FALLTHROUGH()
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static int area(const QSize &s)
Definition qicon.cpp:153
#define qWarning
Definition qlogging.h:166
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
GLboolean r
[2]
GLuint GLuint end
GLenum GLuint id
[7]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLboolean enable
GLsizei GLsizei GLchar * source
struct _cl_event * event
GLfixed GLfixed GLint GLint GLfixed points
GLhandleARB obj
[2]
const GLubyte * c
GLfloat GLfloat p
[1]
GLuint num
#define DEFINE_BOOL_CONFIG_OPTION(name, var)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
Definition qscopeguard.h:60
SSL_CTX int void * arg
#define emit
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:187
QObject::connect nullptr
QPoint oldPosition
[6]
QGraphicsItem * item