This question already has an answer here:
I'm doing some stuff with digitizing and one thing that would nice to have is to get coordinates by mouse click.
My problem is that I don't know how can I create utility similar to this from map tool, where I can easly create method:
def canvasReleaseEvent(self, e): if e.button() == Qt.LeftButton: x = e.pos().x() y = e.pos().y() point = self.iface.mapCanvas().getCoordinateTransform().toMapCoordinates(x, y) print(point)
For example, when user wants to digitizing, he has to show a point on canvas, where to start. To do this, he clicks on a button to call a function for getting coordinates from canvas.
The main problem I struggle with is that I don't know how I can craete method for catching coordinates, that only works when I call it (not like in maptool, when it works all the time).
Is there any way to do that?