I am trying to write a python plugin and want to provide functionality similar to the "Identify feature" tool that already exists in QGIS. Plus the possibility to open the document relied to a feature by getting the path assigned to it in a column. How does one get, after launching the plugin, the clicked feature on mouse click event?
I've used some code from here but I couldn't get it to work.
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
class IdentifyGeometry(QgsMapToolIdentify):
def __init__(self, canvas):
self.canvas = canvas
QgsMapToolIdentify.__init__(self, canvas)
def canvasReleaseEvent(self, mouseEvent):
results = self.identify(mouseEvent.x(),mouseEvent.y(), self.TopDownStopAtFirst, self.VectorLayer)
if len(results) > 0:
self.emit( SIGNAL( "geomIdentified" ), results[0].mLayer, results[0].mFeature)