qgis.utils.iface.activeLayer()
accesses the current active layer, but I would like to get all checked layers in the QGIS ToC.
How can I do it?
in your case qgis.utils.iface.activeLayer()
return the last selected one. To obtain selected layers use the ability of the TreeView that contain the layer list.
More directly:
iface.layerTreeView().selectedLayers()
more detail exploring the class QgsLayerTreeView:
http://qgis.org/api/classQgsLayerTreeView.html
obviously this work after legend refactoring => qgis >= 2.6
layers = qgis.utils.iface.layerTreeRoot().selectedLayers()
but I get en error "QgisInterface object has no attribute layerTreeRoot"