I'm new to QGIS and python as well.

I need attributes and their values of a selected vector layer, in the similar manner as Identify Feature works only difference is I don't wish to show them in a dialog box.

For a better approach I went through Cookbook and few of posts on GIS and have tried function like getFeatures() but no success.

2 Answers 2


if rect is a Qgsrectangle centered in the point clicked on canvas, then the code is synthetically

request = QgsFeatureRequest(rect)
for feat in layer.getFeatures(request):
    <yout code> of the QgsFeature "feat"
def changeValue(self,point,button):
    request = QgsFeatureRequest()

Above function resulted to the string below in lineEdit

  • Luigi's answer is correct. Follow that.
    – Nathan W
    Oct 15, 2014 at 22:58
  • @NathanW First of all thnkx for answering now following Luigi's answer when I tried the code I've posted above this string appeared in the code below <qgis.core.QgsFeatureRequest object at 0X048E2DB0>
    – Prashant
    Oct 16, 2014 at 5:38
  • That is because you are not mean to use it like that. Do exactly what Luigi posted.
    – Nathan W
    Oct 19, 2014 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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