QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
QgsDefaultValue Class Reference

The QgsDefaultValue class provides a container for managing client side default values for fields. More...

#include <qgsdefaultvalue.h>

Public Member Functions

 QgsDefaultValue (const QString &expression=QString(), bool applyOnUpdate=false)
 Create a new default value with the given expression and applyOnUpdate flag.
 
bool applyOnUpdate () const
 The applyOnUpdate flag determines if this expression should also be applied when a feature is updated or only when it's created.
 
QString expression () const
 The expression will be evaluated whenever a default value needs to be calculated for a field.
 
bool isValid () const
 Returns if this default value should be applied.
 
 operator bool () const
 Checks if a default value is set.
 
bool operator== (const QgsDefaultValue &other) const
 
void setApplyOnUpdate (bool applyOnUpdate)
 The applyOnUpdate flag determines if this expression should also be applied when a feature is updated or only when it's created.
 
void setExpression (const QString &expression)
 The expression will be evaluated whenever a default value needs to be calculated for a field.
 

Properties

bool applyOnUpdate
 
QString expression
 

Detailed Description

The QgsDefaultValue class 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

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.

Definition at line 47 of file qgsdefaultvalue.h.

Constructor & Destructor Documentation

◆ QgsDefaultValue()

QgsDefaultValue::QgsDefaultValue ( const QString &  expression = QString(),
bool  applyOnUpdate = false 
)
explicit

Create a new default value with the given expression and applyOnUpdate flag.

See also
QgsVectorLayer::setDefaultValueDefinition

Definition at line 19 of file qgsdefaultvalue.cpp.

Member Function Documentation

◆ applyOnUpdate()

bool QgsDefaultValue::applyOnUpdate ( ) const

The applyOnUpdate flag determines if this expression should also be applied when a feature is updated or only when it's created.

Definition at line 42 of file qgsdefaultvalue.cpp.

◆ expression()

QString QgsDefaultValue::expression ( ) const

The expression will be evaluated whenever a default value needs to be calculated for a field.

Definition at line 32 of file qgsdefaultvalue.cpp.

◆ isValid()

bool QgsDefaultValue::isValid ( ) const

Returns if this default value should be applied.

Returns
false if the expression is a null string.

Definition at line 52 of file qgsdefaultvalue.cpp.

◆ operator bool()

QgsDefaultValue::operator bool ( ) const
explicit

Checks if a default value is set.

Alias for isValid().

Returns
false if the expression is a null string.

Definition at line 57 of file qgsdefaultvalue.cpp.

◆ operator==()

bool QgsDefaultValue::operator== ( const QgsDefaultValue other) const

Definition at line 26 of file qgsdefaultvalue.cpp.

◆ setApplyOnUpdate()

void QgsDefaultValue::setApplyOnUpdate ( bool  applyOnUpdate)

The applyOnUpdate flag determines if this expression should also be applied when a feature is updated or only when it's created.

Definition at line 47 of file qgsdefaultvalue.cpp.

◆ setExpression()

void QgsDefaultValue::setExpression ( const QString &  expression)

The expression will be evaluated whenever a default value needs to be calculated for a field.

Definition at line 37 of file qgsdefaultvalue.cpp.

Property Documentation

◆ applyOnUpdate

bool QgsDefaultValue::applyOnUpdate
readwrite

Definition at line 52 of file qgsdefaultvalue.h.

◆ expression

QString QgsDefaultValue::expression
readwrite

Definition at line 51 of file qgsdefaultvalue.h.


The documentation for this class was generated from the following files: