I need to update a vector layer's data when the visibility is turned back on. My update does not occur when the visibility is off.

To what signal do I need to connect to catch the visibility change?

2 Answers 2


An example to complete @snaileaters's anwser :

def print_informations(layerTreeNode, checkstate):
'''print some informations when a group or a layer is checked'''
    if checkstate:
        if layerTreeNode.nodeType() == 0:
            print "Group " + layerTreeNode.name()
            if layerTreeNode.nodeType() == 1:
                print "Layer " + layerTreeNode.layerName()
                print "Error"

root = QgsProject.instance().layerTreeRoot()

the visibilityChanged signal of a QgsLayerTreeNode object should do the job i think.

  • My answer only applies when checking/unchecking group/layer in the Layer Tree view not when layers appear/disappear due to a scale based visibility setting ...
    – Snaileater
    Jul 2, 2015 at 11:41
  • This may help. How do I get the TreeNode from the layer?
    – Worth Lutz
    Aug 18, 2015 at 18:27

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.