2

QGIS Group Layers don't have properties, probably because of that there also doesn't exist the possibility to define variables for Group layers. I use Project variables and Layer variables but also would need to define Group layer variables.

I read these variables from command line and pass them to a Openlayers web viewer. These variables define things like showing layers as WMS or WFS or which layers to make visible.

Does there exist any plugin or pyqgis code to add Group layer variables? Or is there any discussion on QGIS to add this feature to core?

4
  • 1
    I wonder how would that work because the layers in the group do not need to have the same attributes. What is your concrete aim?
    – user30184
    Commented Sep 24, 2021 at 10:14
  • 1
    I need to define things for my web viewer like visibility in layer selector. I do that for layers but would also need to define that for groups. So it has to be a property save to QGS project. Project variables are a work around but not that elegant as I use them to define properties for Group Layers.
    – geraldo
    Commented Sep 24, 2021 at 10:22
  • 1
    What about using a custom property for both layers and layer groups? I've done that in one of my plugins. Layer tree nodes have custom properties, and both layers and group layers are nodes (see the docs). See how to set it and how to get it. Commented Sep 24, 2021 at 14:11
  • That sounds promising. So I would need to make a plugin to use group.setCustomProperty() and group.getCustomProperty() to handle Layer Group properties. I think that's an answer so if you convert your comment I would accept it. Just one more question to get a better understanding: Are these customProperties in case of layers accessible through QGIS GUI or only using pygis? In case of groups there is no Properties dialog, so I think to know the answer.
    – geraldo
    Commented Sep 25, 2021 at 11:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.