I am using QGIS 3.

I know that i can right click the layer and check the "show feature" option but is it possible to show enable this function by default when any layer is loaded ?

I know that we can set the project. I am looking for option to show it all time. a plugin for it will do.

  • as a note, including Show Feature Count for each layer in a project can result in extended load times as QGIS has to recount each layer when the project is open. Commented Jun 16, 2020 at 16:33

2 Answers 2


You can use the following code in the Python Console, script or plugin which sets the featureCount setting to be enabled for any loaded vector layer:

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


If you want this to work from startup, you can use a startup script (or a plugin) and use the code shown above in addition to importing the following modules:

from qgis.core import QgsMapLayer, QgsProject
  • 1
    This should probably iterate over all the layers received from the signal, not just the first one. Commented May 5, 2022 at 11:30

For any future person reading this thread, there is now an option to show feature count by default when new layer is added.

Go to Settings -> Options -> Canvas & Legend -> tick the box next to Show feature count for newly added layers


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.