[QGIS-Developer] Setting layer properties abstract with pyqgis

Trey Stafford trey.stafford at nsidc.org
Fri Feb 7 15:52:23 PST 2020


Hello,

I have a py-qgis question that someone here may be able to help me with.

We are building a QGIS data package programmatically using pyqgis. One 
of our goals is to include various metadata for the layers we are adding 
to this package, so that when a user opens a layer's properties menu, 
they can see things like the abstract, citation information, etc.

In QGIS, using the GUI, we can add an abstract directly into the 
'Abstract' field in the metadata tab (layer properties popup), and then 
save the project to write that information out to the project file. This 
gets placed in the `abstract` tag under the `resourceMetadata` tag 
associated with the layer in question. My question is: how do we 
programmatically add this abstract information to the project file using 
pyqgis?

There is a `setAbstract` method on QgsMapLayer objects that is used to 
change the on-hover popup text when moving the cursor over the given 
layer in the table of contents, but this does not set the 'metadata' 
abstract in the layer properties popup.

Any advice or suggestions would be appreciated!

Thanks,

Trey Stafford



More information about the QGIS-Developer mailing list