How to turn on/off all labels of all layers in QGIS

Not sure if there is an existing option to do this but using a bit of python, we can always create such a function ourselves!

So we could:

  1. Create a temporary icon on the toolbar which can toggle.
  2. Create a function which enables/disables labeling for each layer depending on the toggle state of the icon.
  3. Connect the icon to the function.

The code could look something like this which you can paste into the Python Console:

from PyQt4.QtCore import QObject, SIGNAL
from PyQt4.QtGui import QAction, QIcon

action = QAction(QIcon(""), "Turn labels" + "\n" + "ON/OFF", iface.mainWindow())
action.setCheckable(True)
iface.addToolBarIcon(action)

def label_control():
    for layer in QgsMapLayerRegistry.instance().mapLayers().values():       
        if action.isChecked() == True:      
            layer.setCustomProperty("labeling/enabled", True)
        else:
            layer.setCustomProperty("labeling/enabled", False)
        layer.triggerRepaint()

QObject.connect(action, SIGNAL("triggered()"), label_control)
# Uncomment line below if you want to remove the icon yourself,
# otherwise it will be removed automatically when you restart QGIS
#iface.removeToolBarIcon(action)

Example:

Couple of layers which have labelling enabled (toggled):

Enabling labels

Same layers but with the labels disabled (untoggled):

Disabling labels

Tags:

Labeling

Qgis