Sunday, 27 March 2016

pyqgis - Setting a default value in a QGIS field


I would like to add in a layer's field a default value. I mean, every time a new feature is created, that field would be automatically filled with the default value.


In my case the default value would be the @project_filename variable (project's file name).


I can't find this functionality anywhere.


Regards,



Answer



Since QGIS 2.18, go to the layer properties / field properties and set an expression (@project_filename in this case) as the default value.


Expression based default values


https://www.qgis.org/en/site/forusers/visualchangelog218/index.html#feature-client-side-default-field-values



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...