Good day

I am using a python script running in the Qgis scripting console to read a list of layers in the table of contents and it is supposed to be able to find out which layer's visibility check box is checked or not by calling the method itemVisibilityChecked.

So I have a top level group in the layer tree whose name is specified in a constant called extentGroupName and I am using the piece of code shown below to evaluate which of the layers in the group have their check box checked or not:

extentGroup = root.findGroup(extentGroupName)

extentLayers = extentGroup.children()

for extentLayer in extentLayers:

    if extentLayer.itemVisibilityChecked:

        print (extentLayer.name())

When I run this code it always prints the name of every layer in the group (I can see that it has the names right so that clearly these layer names have come from that group) but it is clear that the state of the checkbox is always found to be checked as far as the script is concerned so it ignores whether it is actually checked or not and always returns True as the result of calling the method itemVisibilityChecked.

I can't see if there is anything wrong in my code and so it appears there is a bug in that it always returns True for the method itemVisibilityChecked regardless of what it is actually set to.

Qgis 3.28, Linux (both flatpak and LTS deb packages tested)

_______________________________________________
QGIS-User mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to