I'm writing a map editor and I'm having an issue with my implementation of the graphicsview control. When I click down and all of the map is in view, it works great. But when I have only part of the map in view, the mouse coordinates seem to be relative to the new area only.

Basically when the whole map is in view 0,0 is the very top left tile. But when I have only a section in view, the top left viewable section becomes 0, 0. This creates a problem when I draw because that 0, 0 position is on the actual field, in the top left, so it draws on the top left instead. This is how I'm using the mouse coordinates:


Qt Code:
  1. int x = event->pos().x();
  2. int y = event->pos().y();
  3.  
  4. if(x < 0 || y < 0)
  5. return;
  6.  
  7. if(x > ((activeGrid->getWidth()) - 1) || y > ((activeGrid->getHeight()) - 1))
  8. return;
  9.  
  10. x = (x) / (TILE_SIZE);
  11. y = (y) / (TILE_SIZE);
  12.  
  13. mouseX = x;
  14. mouseY = y;
  15.  
  16. emit(mouseMoved(QPoint(mouseX, mouseY)));
To copy to clipboard, switch view to plain text mode 

Is there a way to get the X & Y cordinates of the graphicsview as a whole and NOT relative to the section viewable?