I am displaying multiple QGraphicsPolygonItem's inside a QGraphicsView. When I hover the mouse inside one of the QGraphicsPolygonItem, I need the pixel position under the mouse relative to the Upper Left Hand Corner of the QGraphicsPolygonItem. I have overloaded the mouseMoveEvent of QGraphicsPolygonItem, and am trying to get the values on mousemove (Code below).

Qt Code:
  1. void MovablePolygonItemWithHistogram::mouseMoveEvent( QGraphicsSceneMouseEvent * event ){
  2.  
  3. QRectF myBoundingRectangle = this->sceneBoundingRect();
  4. QPoint currPos = this->pos();
  5.  
  6. QPoint currMousePoint = QCursor::pos();
  7. QPointF currMousePointF = this->mapToScene(currMousePoint);
  8. QPointF currEventPoint = event->pos();
  9.  
  10. int xRelative = currMousePointF.x() - myBoundingRectangle.topLeft().x();
  11. int yRelative = currMousePointF.y() - myBoundingRectangle.topLeft().y();
  12. MovableRectangle::mouseMoveEvent(event);
  13. }
To copy to clipboard, switch view to plain text mode 

QCursor::pos() gives me the correct mouse coordinates WRT the computer screen. However, myBoundingRectangle always returns the position where I placed it on the parent QGraphicsView. If I try to find location of the QGraphicsPolygonItem using pos() or scenePos() (currPos), it is always 0, 0.

What should I be doing to get xRelative and yRelative? I read through "The Graphics View Coordinate System" at http://developer.qt.nokia.com/doc/qt...rdinate-system, and am possibly missing something simple here. Would appreciate any pointers.