1

I have two simple classes, one calls another. One of the classes is QGIS map tool and only returns the position of the clicked event to the method which activates maptool. I don't know how to do this. The following is the structure I am trying to do. These two classes are located in two different modules

class Class1:
    def __init__(self):
        """Constructor."""

    def get_location(self):
        canvas = iface.mapCanvas()
        clicked_points=canvas.setMapTool(Class2(self,canvas))
        print(clicked_points)
        iface.actionPan().trigger()

class Class2(QgsMapTool):
    def __init__(self,canvas):
        QgsMapTool.__init__(self, canvas)
        self.setCursor(Qt.CrossCursor)
        self.parent_class=parent_class

    def canvasReleaseEvent(self, event):
        return [event.pos().x(),event.pos().y()]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.