[QGIS-Developer] pyqgis how set filter legend map content in layer panel

Richard Duivenvoorde rdmailings at duif.net
Mon May 10 23:41:21 PDT 2021


On 5/11/21 12:04 AM, Enzo Cocca wrote:
> Hi Alex,
> Thanks for replay.
> Im speaking about the legend into layer panel. I'm not understand if I can set the filter legend on map when load an view with a style into layer panel. Into layer panel exist an check toolbox for this and so i would activate it when load my view or better if possible set the filter just on specific vectors.

Not sure, but you are talking about rule base styling, and you want to change the visibility of one of the 'rules' as if you check the class/rule in the Layer Manager (or in the Rulebased symbology panel)?

If so: maybe you can do it via the layer tree api?
https://www.lutraconsulting.co.uk/blog/2014/07/06/qgis-layer-tree-api-part-1/

Find the specific node and enable/disable it?

Another option is go into the symbology, find the Rule and disable it by using setActive?
https://qgis.org/api/3.18/classQgsRuleBasedRenderer_1_1Rule.html#a8306b64ca0ad4371fce04f4297647d35

But to be honest: I've no experience with it

Regards,

Richard Duivenvoorde




More information about the QGIS-Developer mailing list