mep
mep

Reputation: 351

Get absolute mouse click location on widget (also when zoomed in) Qt

I want to trigger where I click with the mouse on my QGraphicsView. Problem here: this QGraphicsView is always zoomed in. But I want to get the point relative to the whole widget and not only to the viewport. Or in other words: when I zoomed in and click on the upper left corner, the location should NOT be 0,0 (the QMousePressEvent just gives me this point). It should be the distance from there to the upper left corner of the whole sceneRectangle (or to the middle, doesn't matter). Is there any way to do this? Thanks for answers.

Upvotes: 1

Views: 370

Answers (1)

Jesper Juhl
Jesper Juhl

Reputation: 31447

You can do what you want with Qt's mapToScene function.

Upvotes: 2

Related Questions