3

I would like to make use of Signal and Slot while using PyQgis along with PyQt4.

Despite spending some time trying out tutorials and some somewhat related post on gis.stackexchange I can't figure out a proper way of using the canvasClicked signal returned from the QgsMapToolEmitPoint Class (API doc).

Here after is where I'm at. I am building my application from the few tutorials man can find over the internet.

    self.clickPoint_action = QAction(
        QIcon(":/ourapp/zoomin_icon"),
        "Click Point",
        self)


    # create toolbar
    self.toolbar.addAction(self.clickPoint_action)

    # connect the tool
    self.clickPoint_action.triggered.connect(self.clickPoint)


    # create the map tool(s)
    self.tool_clickPoint = QgsMapToolEmitPoint(self.map_canvas)


def clickPoint(self):
    self.map_canvas.setMapTool(self.tool_clickPoint) 

So, I understand how to set my map tool (and successfuly use other built-in and custom MapTool), but can't figure out where to go from there to get the corresponding QgsPoint emitted after a mouse click.

I have few experience on Python and just dive into Qt and PyGIS but already have some background mostly wth java.

thanks for sharing!

1

You are just missing the connect for the clicked signal:

 self.tool_clickPoint.canvasClicked.connect(self.clicked)


 def clicked(self, point, button):
    ....
1
  • That perfectly answers my question. Very clear. But I don't understand where that was described in the API doc. Jul 7 '14 at 12:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.