Skip to main content
edited body
Source Link

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.layerTreeRootlayerTreeView().selectedLayers()

more detail exploring the class QgsLayerTreeView:

http://qgis.org/api/classQgsLayerTreeView.html

obviously this work after legend refactoring => qgis >= 2.6

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.layerTreeRoot().selectedLayers()

more detail exploring the class QgsLayerTreeView:

http://qgis.org/api/classQgsLayerTreeView.html

obviously this work after legend refactoring => qgis >= 2.6

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

Source Link

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.layerTreeRoot().selectedLayers()

more detail exploring the class QgsLayerTreeView:

http://qgis.org/api/classQgsLayerTreeView.html

obviously this work after legend refactoring => qgis >= 2.6