[Qgis-user] Display number of features present in layer's Attribute Table

Ann Tulliani anntulliani at aol.com
Thu Feb 4 10:11:47 PST 2021


Hi Andrea,
Thanks, that did the trick. Now I have all layers always displaying feature count, which is of huge help.
Ann


-----Original Message-----
From: Andrea Giudiceandrea <andreaerdna at libero.it>
To: qgis-user at lists.osgeo.org
Sent: Thu, Feb 4, 2021 3:17 am
Subject: Re: [Qgis-user] Display number of features present in layer's Attribute Table

Ann Tulliani wrote
> The one proposed workaround I found online
> is https://gis.stackexchange.com/questions/318190/setting-qgis-to-show-feature-count-always-when-layer-is-loaded.
> Following it, inside my /home/tulliani/.qgis2/python/startup.py I have:

Hi Ann,
are you using QGIS 2.x?



Ann Tulliani wrote
> Does anyone have any suggestions on how to update that code to make it
> work for multiple addition of layers?


You could try with:

def showFeatureCount(layers):
    for layer in layers:
        if layer.type() == QgsMapLayer.VectorLayer:
            root = QgsProject.instance().layerTreeRoot()
            myLayerNode = root.findLayer(layer.id())
            myLayerNode.setCustomProperty("showFeatureCount", True)


Regards.

Andrea Giudiceandrea



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html
_______________________________________________
Qgis-user mailing list
Qgis-user at lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210204/59589f5b/attachment.html>


More information about the Qgis-user mailing list