Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74935

Getting collided items with ContainsItemShape is not working as expected

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 4.7.4, 5.12.1, 5.12.2, 5.13.2, 5.14.0
    • Widgets: GraphicsView
    • None
    • All

    Description

      Hello,

      There is a bug (at least since Qt 4.7.4 where I first seen it, and then tested on Qt 5.12.1 where it is still present) while calling QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) with mode = Qt::ContainsItemShape, indeed, it seems it is not actually working on item shape but on bounding box instead.

      In the project I attached, we can clearly see that green and red shapes are fully inside the blue one, but only green is found when calling QGraphicsScene::items function (see output qDebug after application run), and, what make me think that it works on bounding box instead is that green shape (that is detected) has actually its bounding box fully inside blue shape but the red one (that is not detected) has its shape but not its bounding box inside the blue shape, also, in Widget.cpp in attached project, if you define BUG_BEHAVIOUR to 0 instead of 1, the red shape will be moved so that its bounding box is also inside the blue one and then will now actually be detected inside.

      Also, I tried several other "collidingItems" functions but they are not working at all (always finding no item), you can see all in Widget::GetCollidings function.

      Thanks for looking at this.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bibr Andreas Aardal Hanssen
            gluttony Gluttony P.
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes