Skip to main content
Tweeted twitter.com/StackGIS/status/1533916652861018119
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

How can I set the transparency for all layers within a group of layers?

I assume this will require the use of a FOR loop in the Python Console.

Based on How to set the transparency for multiple layers or add a global transparancy preference?How to set the transparency for multiple layers or add a global transparancy preference?

I tried the following:

for layer in iface.legendInterface().layers():
   layer.renderer().setOpacity(0.5)

But I only get this error:

Traceback (most recent call last):
  File "<input>", line 2, in <module>
AttributeError: 'QgsVectorLayer' object has no attribute 'renderer'

What am I doing wrong?

How can I set the transparency for all layers within a group of layers?

I assume this will require the use of a FOR loop in the Python Console.

Based on How to set the transparency for multiple layers or add a global transparancy preference?

I tried the following:

for layer in iface.legendInterface().layers():
   layer.renderer().setOpacity(0.5)

But I only get this error:

Traceback (most recent call last):
  File "<input>", line 2, in <module>
AttributeError: 'QgsVectorLayer' object has no attribute 'renderer'

What am I doing wrong?

How can I set the transparency for all layers within a group of layers?

I assume this will require the use of a FOR loop in the Python Console.

Based on How to set the transparency for multiple layers or add a global transparancy preference?

I tried the following:

for layer in iface.legendInterface().layers():
   layer.renderer().setOpacity(0.5)

But I only get this error:

Traceback (most recent call last):
  File "<input>", line 2, in <module>
AttributeError: 'QgsVectorLayer' object has no attribute 'renderer'

What am I doing wrong?

edited tags; edited title
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

set the Setting transparency of layer group with Python in QGIS?

Source Link
Clay
  • 401
  • 4
  • 12

set the transparency layer group with Python

How can I set the transparency for all layers within a group of layers?

I assume this will require the use of a FOR loop in the Python Console.

Based on How to set the transparency for multiple layers or add a global transparancy preference?

I tried the following:

for layer in iface.legendInterface().layers():
   layer.renderer().setOpacity(0.5)

But I only get this error:

Traceback (most recent call last):
  File "<input>", line 2, in <module>
AttributeError: 'QgsVectorLayer' object has no attribute 'renderer'

What am I doing wrong?