QGIS-Documentation
QGIS-Documentation copied to clipboard
Add map layers custom properties to the information tab (Request in QGIS)
Request for documentation
From pull request QGIS/qgis#55493 Author: @jadsilva QGIS version: 3.36
Add map layers custom properties to the information tab
PR Description:
Fixes qgis#52243
Description
Commits tagged with [need-docs] or [FEATURE]
A new list item to add in the layer properties --> information section of the "working with..." chapters.
@jadsilva @rduivenvoorde what do these custom properties refer to? Where do they come from or how can we create them?
@DelazJ you can set, using python, so called 'custom properties' on some objects: https://qgis.org/pyqgis/master/search.html?q=setCustomProperty
In this case these are custom properties on a MapLayer: https://qgis.org/pyqgis/master/core/QgsMapLayer.html#qgis.core.QgsMapLayer.setCustomProperty
Let me create an example and screenie...
These custom properties are being saved into the projects xml too. So it is for example possible to 'save' some state information into a project. I use it for example to save an object with some info about last used layers etc.
To see it:
# first load 'world', via easter egg, by typing 'world' in the coordinate input
# then open the python console
# make sure the world layer is the active layer
# now create a property:
iface.activeLayer().setCustomProperty('custom_property_name', 'custom_property_value')
# or read it from the layer/project:
iface.activeLayer().customProperty('custom_property_name')
'custom_property_value'
So before this PR, you could check the value via Python, or inspect the xml of the project, but it was not visible in the UI.
Now you can see it in the Layer-properties, in the information tab: