Is it possible to have a transparency slider shown by default in the Layer window, i.e. directly after adding a new layer, instead of having it to enable for each layer manually via layer-properties?
This was briefly mentioned in QGIS - Developer forum where you need to use QgsMapLayer::setCustomPropertylayer to enable the embedded widget for your layer. We can then add an
itemAdded event so that whenever a layer is added, it will automatically be shown with the transparency widget.
So you could use something like the following in the Python Console:
def transparency_slider(): for layer in QgsMapLayerRegistry.instance().mapLayers().values(): if layer.customProperty("embeddedWidgets/count") != 1 or layer.customProperty("embeddedWidgets/0/id") != u'transparency': layer.setCustomProperty("embeddedWidgets/count", 1) layer.setCustomProperty("embeddedWidgets/0/id", "transparency") else: pass qgis.utils.iface.legendInterface().refreshLayerSymbology(layer) # Connect "itemAdded" event to "transparency_slider" function legend = qgis.utils.iface.legendInterface() legend.itemAdded.connect(transparency_slider)
Tested on QGIS 2.18.3 for Win7 64-bit.
Inserting code into python console and before adding shapefiles:
There is a plugin called Raster Transparency, that as the name suggests, will open a dockable panel with sliders for changing the transparency of a selected raster layer.
Go to Plugins > Manage and install plugins - Find it and install, a new associated icon will appear on your toolbars.