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!
Answer
You are just missing the connect for the clicked signal:
self.tool_clickPoint.canvasClicked.connect(self.clicked)
def clicked(self, point, button):
....
No comments:
Post a Comment