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?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
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() else: if layerTreeNode.nodeType() == 1: print "Layer " + layerTreeNode.layerName() else: print "Error" root = QgsProject.instance().layerTreeRoot() root.visibilityChanged.connect(print_informations)