How can I set the transparency to 27 % for all 245 layers in QGIS? The only way I know of is by right clicking on the layer name, selecting Properties, then Transparency and then moving the transparency slider left or right.


This is simple enough. But this is only good for up to 10 layers maybe. What if you have 245 layers like I do? Do you just keep on repeating the process? Now surely, there there must be a way to apply this to all 245 layers at once!?


Alternatively, is there a global transparency preference setting I can add in so that when I add new layers they automatically get 27 % transparency?

The QGIS online documentation mentions something about exporting your transparency setting to a file for a later use.

As you can see this is quite easy to set custom transparency, but it can be quite a lot of work. Therefore you can use the button Export to file to save your transparency list to a file. The button Import from file loads your transparency settings and applies them to the current raster layer.

This seems like a useful feature. But I don't think this is what I'm looking for.

I tried selecting multiple layers in the table of contents and then right click and select Properties and set the transparency level, apply changes and click OK. It applied the changes, but only to the last layer in the selection, the one I right clicked on. None of the other layers in the selection were affected. (This could be a bug actually.)

5 Answers 5


A little python script like this would do it

for layer in iface.legendInterface().layers():

Just copy and paste that into the python console (which is shown via Plugins->Python console) and hit enter twice. The script will loop through all layers and set their opacity to 20%.

For QGIS 3.x you need a slightly different Python script because the API has changed significantly:

layers = qgis.core.QgsProject.instance().layerTreeRoot().layerOrder()
for layer in layers:
# Redraw the layers so you can see the effect
  • 1
    Is it possible to do the same when you have also vector layers? Like do it only for selected layers, or for layers inside one same group?
    – Victor
    Commented Sep 4, 2015 at 14:26
  • this doesn't seem to work anymore in 2.8.2, i see a rendererV2 in the docs instead of renderer, but it doesnt have the setOpacity method :(
    – chrismarx
    Commented Jan 18, 2016 at 0:03
  • i see this ticket that would suggest layer groups could do this, but i don't see how either - trac.osgeo.org/qgis/ticket/557
    – chrismarx
    Commented Jan 18, 2016 at 0:06
  • For GQIS3 replace first line w: for layer in [layer for layer in QgsProject.instance().mapLayers().values()]: per this: gis.stackexchange.com/questions/273576/…
    – andrew
    Commented Aug 20, 2018 at 18:18

Another option, requiring no python, is to simply edit you project file.

Raster layer transparency is set with: rasterrenderer opacity="1"

You can open your project file .qgs in a text editor and find and replace: rasterrenderer opacity="1" With: rasterrenderer opacity="0.73"


The easiest way to do this is by using layer styles. Just set the transparency of a single layer to 27% and copy/paste the style to all other layers. You can paste a style to multiple layers at once.

See also:


  • 1
    no because that will copy over everthing else, including the symbology/colours/view extents.
    – Theo F
    Commented Nov 6, 2017 at 12:18
  • Underrated answer ! Work perfectly when we're only working on transparency
    – Eliasse
    Commented Mar 5, 2020 at 9:39

update for qgis 3.x

Use the group transparency plugin: https://plugins.qgis.org/plugins/group_transparency/

old answer for qgis 2.x:

You may use this QGIS Processing script to set transparency for a specific group: https://github.com/jkall/qgis-processing-scripts/blob/master/set_transparency_for_group.py

  1. Group layers.
  2. Open group's styling tab.
  3. Set checkbox Render Layers as a Group checked.
  4. Change group opacity.

enter image description here

  • How do you get the Layer Styling window?
    – zabop
    Commented Apr 4 at 10:00
  • @zabop Right-click on an empty space on the QGIS panel (not on the map). Find the Layer Styling Panel and click on it. Commented Apr 4 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.