diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-02-05 18:11:34 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-12 18:46:52 +0100 |
commit | 536c9481170c7cd84e5e78edf99ebc943d439b1a (patch) | |
tree | 736dd4209e5f2a1f11d58bb0da20d03f49a5feca | |
parent | edb924b93c55dc5576849b2e93ba55fc7ee0df63 (diff) |
QQuickItem::childAt(x, y) takes child transformations into account
Task-number: QTBUG-28706
Change-Id: Ib1738eac1319361398b1898db341d6e4be0fe5fd
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
-rw-r--r-- | src/quick/items/qquickitem.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index e87f870eb8..26af6953e1 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -3808,14 +3808,15 @@ void QQuickItem::forceActiveFocus() */ QQuickItem *QQuickItem::childAt(qreal x, qreal y) const { - // XXX todo - should this include transform etc.? const QList<QQuickItem *> children = childItems(); for (int i = children.count()-1; i >= 0; --i) { QQuickItem *child = children.at(i); - if (child->isVisible() && child->x() <= x - && child->x() + child->width() >= x - && child->y() <= y - && child->y() + child->height() >= y) + // Map coordinates to the child element's coordinate space + QPointF point = mapToItem(child, QPointF(x, y)); + if (child->isVisible() && point.x() >= 0 + && child->width() >= point.x() + && point.y() >= 0 + && child->height() >= point.y()) return child; } return 0; |