[Qgis-developer] Qgis Api - get a layer by its name

kimaidou kimaidou at gmail.com
Tue Nov 9 09:59:32 EST 2010


Hi List

I have not found any function in QgsMapLayer for getting a layer by its
name. I needed it on a python plugin to let the user choose a layer from a
combo box (already populated with the layer names)
So I created this function http://osgeo.pastebin.com/7EpNA3JL

I have some questions regarding it:
* Is it the right way ?
* I have seen it is possible in Qgis to rename a layer, and 2 layers of the
same type can have the same name. This makes my function not working in all
the cases (which is my problem of course). Is there a reason to allow layers
to share a name ?

Thanks for all the work done in Qgis

Cheers

Kimaidou
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20101109/892b44c4/attachment.html


More information about the Qgis-developer mailing list