[Qgis-developer] QgsMapLayerRegistry.mapLayers() not available in Python Bindings

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Jan 11 05:40:01 EST 2008

Düster Horst wrote:
> With Python I want to get all avalilable map layers from my current
> project. I tried to do this with 
> layerCollection = QgsMapLayerRegistry().instance().mapLayers()
> It doesn't work. I took a look into qgsmaplayerregistry.sip and found
> out that the method mapLayers() is not wrapped until now. What is to do
> to wrap this method. Does exists a workareound to retrieve all project
> layers.

You can get all the layers in the current map canvas from the console thus:

# get the map canvas

# how many layers are there?

# loopage:

for l in range(nLayers):
   layer = mc.getZpos(l)

  - is that good enough?


More information about the Qgis-developer mailing list