Class: QgsExpressionFieldBuffer

class qgis.core.QgsExpressionFieldBuffer

Bases: sip.wrapper

Constructor for QgsExpressionFieldBuffer.

QgsExpressionFieldBuffer(QgsExpressionFieldBuffer)

Buffers information about expression fields for a vector layer.

Methods

addExpression

Add an expression to the buffer

expressions

rtype

List[QgsExpressionFieldBuffer.ExpressionField]

readXml

Reads expressions from project file

removeExpression

Remove an expression from the buffer

renameExpression

Renames an expression field at a given index

updateExpression

Changes the expression at a given index

updateFields

Adds fields with the expressions buffered in this object to a QgsFields object

writeXml

Saves expressions to xml under the layer node

class ExpressionField(exp: str, fld: QgsField)

Bases: sip.wrapper

QgsExpressionFieldBuffer.ExpressionField(QgsExpressionFieldBuffer.ExpressionField)

cachedExpression
field
addExpression(self, exp: str, fld: QgsField)

Add an expression to the buffer

Parameters
  • exp (str) – expression to add

  • fld (QgsField) – field to add

expressions(self)List[QgsExpressionFieldBuffer.ExpressionField]
Return type

List[QgsExpressionFieldBuffer.ExpressionField]

readXml(self, layer_node: QDomNode)

Reads expressions from project file

Parameters

layer_node (QDomNode) –

removeExpression(self, index: int)

Remove an expression from the buffer

Parameters

index (int) – index of expression to remove

renameExpression(self, index: int, name: str)

Renames an expression field at a given index

Parameters
  • index (int) – The index of the expression to change

  • name (str) – New name for field

New in version 3.0.

updateExpression(self, index: int, exp: str)

Changes the expression at a given index

Parameters
  • index (int) – The index of the expression to change

  • exp (str) – The new expression to set

New in version 2.9.

updateFields(self, flds: QgsFields)

Adds fields with the expressions buffered in this object to a QgsFields object

Parameters

flds (QgsFields) – The fields to be updated

writeXml(self, layer_node: QDomNode, document: QDomDocument)

Saves expressions to xml under the layer node

Parameters
  • layer_node (QDomNode) –

  • document (QDomDocument) –