Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to list all QQuickItems within a certain rectangle?
Forum Updated to NodeBB v4.3 + New Features

How to list all QQuickItems within a certain rectangle?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 217 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    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 is

    bool 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 cryptic

    containmentMask : QObject*
    

    without any interface description.

    Have I missed anything? How would you implement locating items via rectangle?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved