Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to the Quantum Plugin development and wonder if there is more information about the following.

I have added a shape file and am (off course) able to select a point from this shape file. In the shape file I have stored the location (x,y) and an id.

Now I would like to be able to select a point in this layer and then my plugin should be able to recognize the id of the point, look up a database and display a graphical representation of the data in the database.

So what I am looking for is this,

  • how do I get the information of a selected point to my plugin
  • is it possible that my plugin overwrites the default information dialog (so the plugin pops up instead of the normal dialog)
  • is there perhaps a plugin that already shows such behaviour and I can learn from (haven't found one so far)

Thanks (very much) in advance! Rob

share|improve this question
I found the answer (thanks to the advice of Giovanni) in the following excellent workshop;… Works like a charm! – BreinBaas Nov 13 '12 at 14:28

for the first question (obtain informations from the selected feature) I suggest you to connect the layer's selectionChanged() event to a method of your plugin:

self.mylayer = qgis.utils.iface.mapCanvas().currentLayer() #Obtain a raference to the layer you're interested in

In you could code something like in this snippet.

For the information dialog, you can write your own QDialog, and show up whatever you want. The simplest workflow would be:

  1. The user selects the feature
  2. and clicks on your "tool", which will extracts the informations from the selected feature and popup your dialog.

Obviously you have to take care that the layer isn't deleted, the selected layer isn't changed, etc. between point 1 and point 2.

Otherwise, write your own "select/identify" maptool, subclassying QgsMapTool or QgsMapToolEmitPoint


PS: read carefully the PyQgis Cookbook ;)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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