Class: QgsDefaultValue¶
Provides a container for managing client side default values for fields.
A QgsDefaultValue consists of an expression string that will
be evaluated on the client when a default field value needs to be
generated.
Usual values for such an expression are
now()for a timestamp for a record@some_variable to insert a project or application level variable like the username of the one digitizing a feature
$length to insert a derived attribute of a geometry
QgsDefaultValue also has a applyOnUpdate flag which will
indicate that a default value should also be applied when a feature is
updated. If this is not set, the default value will only be used when a
feature is created.
Methods
The applyOnUpdate flag determines if this expression should also be applied when a feature is updated or only when it's created. |
|
The expression will be evaluated whenever a default value needs to be calculated for a field. |
|
Returns if this default value should be applied. |
|
The applyOnUpdate flag determines if this expression should also be applied when a feature is updated or only when it's created. |
|
The expression will be evaluated whenever a default value needs to be calculated for a field. |
- class qgis.core.QgsDefaultValue[source]¶
Bases:
object- __init__(expression: str | None = '', applyOnUpdate: bool = False)
Create a new default value with the given
expressionandapplyOnUpdateflag.- Parameters:
expression (Optional[str] = '')
applyOnUpdate (bool = False)
- __init__(a0: QgsDefaultValue)
- Parameters:
a0 (QgsDefaultValue)
- applyOnUpdate(self) bool[source]¶
The applyOnUpdate flag determines if this expression should also be applied when a feature is updated or only when it’s created.
- Return type:
bool
- expression(self) str[source]¶
The expression will be evaluated whenever a default value needs to be calculated for a field.
- Return type:
str
- isValid(self) bool[source]¶
Returns if this default value should be applied.
- Return type:
bool
- Returns:
Falseif the expression is a null string.