I'm using Qt 4.8.4 on Qt Creator 2.0.1.

I have created a new widget to replace QGraphicsView on my mainwindow, in order to override wheelevents, mousepressevents, etc. I logically inherit QGraphicsView.

I'm using a mousemoveevent to show the coordinates on a label, also on the widget.

This is my code

Qt Code:
  1. void Graph::mouseMoveEvent(QMouseEvent *event)
  2. {
  3. QPointF position = event->posF();
  5. ui->mouse_coordinates->setText("( " + QString::number((int)position.x())
  6. + ", " + QString::number((int)position.y())
  7. + " )");
  8. }
To copy to clipboard, switch view to plain text mode 

But this always show the coordinates in the widget's window (being (0, 0) the top left corner). Because I use zoom and scroll bars on my reimplemented QGraphicsView, these absolute coordinates are useless, since I need this to identify points in a graph drawn in the View.

Is there a way of converting these coordinates to the QGraphicsView referential, i.e., for example, if I have a square drawn at the QGraphicsView (0, 0) (that's not located at the top left corner), how do I get the coordinates (0, 0) when my mouse hovers that square?

P.S.: I have tried this with mousepressevent as well with the same result

Thank you,
Bernardo M.