// Copied with minor modifications from qtdeclarative/src/quick/items/qquickwindow.cpp QMouseEvent *TouchDispatcher::touchToMouseEvent( QEvent::Type type, const QTouchEvent::TouchPoint &p, ulong timestamp, Qt::KeyboardModifiers modifiers, bool transformNeeded) { QQuickItem *item = m_targetItem.data(); // The touch point local position and velocity are not yet transformed. QMouseEvent *me = new QMouseEvent(type, transformNeeded ? item->mapFromScene(p.scenePos()) : p.pos(), p.scenePos(), p.screenPos(), Qt::LeftButton, (type == QEvent::MouseButtonRelease ? Qt::NoButton : Qt::LeftButton), modifiers); me->setAccepted(true); me->setTimestamp(timestamp); QVector2D transformedVelocity = p.velocity(); if (transformNeeded) { QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); QMatrix4x4 transformMatrix(itemPrivate->windowToItemTransform()); transformedVelocity = transformMatrix.mapVector(p.velocity()).toVector2D(); } // Add these later if needed: //QGuiApplicationPrivate::setMouseEventCapsAndVelocity(me, event->device()->capabilities(), transformedVelocity); //QGuiApplicationPrivate::setMouseEventSource(me, Qt::MouseEventSynthesizedByQt); return me; }
QList<QQuickItem *> QQuickViewInspector::itemsAt(const QPointF &pos) const { QQuickItem *root = m_view->contentItem(); QList<QQuickItem *> resultList; collectItemsAt(root, root->mapFromScene(pos), m_overlay, resultList); return resultList; }
QQuickItem *QQuickViewInspector::topVisibleItemAt(const QPointF &pos) const { QQuickItem *root = m_view->contentItem(); return itemAt(root, root->mapFromScene(pos), m_overlay); }