When programmatically applying a subset string to a vector layer (here: ax_flurstueck
with object count 34265)
via
l = iface.activeLayer()
l.setSubsetString('gemarkungsnummer in ('2760','2765','2771','2780','2786','2800','2811','2817','2836')')
the map canvas refreshes automatically, but not the object count in the layer tree (displays still 34265 objects):
When moving the main window around or changing the width of the layer tree or something like that, the layer tree refreshes (21581 objects).
The question is, how to achieve this programmatically? I did not find something like:
QgsLayerTreeView.refesh()
in analogy to refreshing the map canvas. Am I missing something?
Best Answer
This is a quick response but this code work perfectly,and you can refresh featurecount on QgsLayerTreeView.
1:Option
2: Option
Replicate core code in Python.