Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.4.0
-
None
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.