mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Allows an expression to be set for a vector layer field which is used to evaluate a default value for this field. A new method, QgsVectorLayer::defaultValue( int index, const QgsFeature& feature = QgsFeature(), QgsExpressionContext* context = nullptr ) has been added which evaluates the default value for a given field using the optionally passed feature and expression context. This allows default values to utilise properties of the feature which exist at the time of calling, such as digitized geometries. The expression context parameter allows variables to be used in default value expressions, making it easier to eg insert a user's name, current datetime, project path, etc Default values are set using QgsVectorLayer::setDefaultValueExpression() and retrieved using defaultValueExpression()