How to list all QQuickItems within a certain rectangle?
-
In order to implement a lasso selection for my QML scene, I need a way to determine which QQuickItems are within a given rectangle (my lasso).
Preferably, I would handle this on the C++ side, but if a good QML solution exists, I'm interested as well.Coming from QGraphicsView, I am used to be pampered with methods such as
QList<QGraphicsItem *> items(const QRect &rect, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const
which simply return what I want, no questions asked.
Even if I were to implement the logic myself,
QPainterPath QGraphicsItem::shape() const
returns a QPainterPath, which has a handy 'intersects' method for rectangles.
In contrast, I couldn't find a single QRect/QRectF-based method on QQuickView that might help me.
On the QQuickItem side, there isbool QQuickItem::contains(const QPointF &point) const
which only takes a point. How am I going to match a rectangle against this?
There is also an optional and crypticcontainmentMask : QObject*
without any interface description.
Have I missed anything? How would you implement locating items via rectangle?