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

QGraphicsItem::collidesWithItem() does not take ItemIgnoresTransformations into consideration

    XMLWordPrintable

Details

    Description

      Consider the following example:

      QGraphicsRectItem *p1 = scene->addRect(-100, -20, 200, 40, QPen(Qt::red));
      QGraphicsItem *item1 = new QGraphicsRectItem(-80, -10, 160, 20, p1);
      item1->setFlag(QGraphicsItem::ItemIgnoresTransformations);
      p1->setPos(0, -25);
      p1->rotate(90);

      QGraphicsRectItem *p2 = scene->addRect(-100, -20, 200, 40, QPen(Qt::green));
      QGraphicsItem *item2 = new QGraphicsRectItem(-80, -10, 160, 20, p2);
      p2->setPos(0, 25);

      qDebug() << item1->collidesWithItem(item2);

      The expected result is that collidesWithItem() returns false, since the two items do not collide.

      The actual result is that collidesWithItem() returns true.

      Update: The item doesn't know if it collides or not, only the view knows this (since the view decides such item geometries, and not the item or the scene). You can call QGraphicsItem::deviceTransform() to construct a transform that can you can use to do manual collision detection. We'll keep this task around to see if there's anything we can do, but we can only improve the documentation for now.

      Attachments

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

        Activity

          People

            hanssen Andreas Aardal Hanssen (closed Nokia identity) (Inactive)
            sthomass Stian Sandvik Thomassen (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes