Hi

I hava a problem with collision detection. in the picture below the lable Cargo5.5 dosn't detect collision with the QGraphicsPathItem belonging to Cargo6. The outline of the lables is the shape() of the item.

http://www.tiny.cc/ShWEW

the implementation of shape() looks like this

Qt Code:
  1. QPainterPath SVGText::shape() const
  2. {
  3. path.addRect(this->boundingRect().adjusted(0,4,0,-4));
  4. return path;
  5. }
To copy to clipboard, switch view to plain text mode 

and the function where i test for collision, this is where the m_pTextItem e.g Cargo5.5 dosn't detect collision with the QGraphicsPathItem
altough the shape of Cargo5.5 intersects/contains with the QGraphicsPathItem of Cargo6

Qt Code:
  1. int SVGPath::TextCollitionCount()
  2. {
  3. int collCount = 0;
  4. QList<QGraphicsItem *> collidingWithList = m_pTextItem->collidingItems(Qt::ContainsItemShape);
  5. collCount = collidingWithList.count();
  6. if(collCount)
  7. {
  8. for(QList<QGraphicsItem*>::iterator it = collidingWithList.begin();it != collidingWithList.end();)
  9. {
  10. if((*it)->type() == SVGPath::Type)
  11. {
  12. SVGPath *item = qgraphicsitem_cast<SVGPath *>(*it);
  13. if(m_pTextItem->collidesWithPath(item->shape(),Qt::ContainsItemShape))
  14. it++;
  15. else
  16. it = collidingWithList.erase(it);
  17. }
  18. }
  19. }
  20. }
To copy to clipboard, switch view to plain text mode 

is there something i have missed? stacking of items shouldn't matter should it? this application has no paint event etc it's sort of a static presentation (for now) so everyting is added to the scene and later on i set scene to the view.

Regards Muffin www.a-eon.com