[Qgis-developer] Get Feature Id on clicked point

luca_manganelli at comune.trento.it luca_manganelli at comune.trento.it
Wed Mar 17 03:06:47 EDT 2010


qgis-developer-bounces at lists.osgeo.org scritti il 16/03/2010 19.34.14

> Hi All
> I am trying to build an application in which I am unable
> to retrieve the featureId of the Feature at user clicked point,
> instead it is giving featureId one by one sequentially...
> can any one help by giving some code in python.

See this line:

         provider.select(allAttrs, QgsRect(), False)


you should use QgsRect ( x0, y0, x1, y1) to limit the search range.
Otherwise, it will return all features.

an example, taken from your source code:

         provider.select(allAttrs, QgsRect(p.x(0)-0.5, p.y(0)-0.5,
p.x(0)+0.5, p.y(0)+0.5), False)


try it!

p.s. Please don't answer *directly* to me, but to the group!



More information about the Qgis-developer mailing list