Class: QgsOptionalExpression

class qgis.core.QgsOptionalExpression

Bases: QgsOptionalQgsExpressionBase

An expression with an additional enabled flag.

This can be used for configuration options where an expression can be enabled or disabled but when disabled it shouldn’t lose it’s information for the case it gets re-enabled later on and a user shouldn’t be force to redo the configuration.

New in version 2.18.

QgsOptionalExpression() Construct a default optional expression. It will be disabled and with an empty expression.

QgsOptionalExpression(expression: QgsExpression) Construct an optional expression with the provided expression. It will be enabled.

QgsOptionalExpression(expression: QgsExpression, enabled: bool) Construct an optional expression with the provided expression and enabled state.

QgsOptionalExpression(QgsOptionalExpression)

Methods

readXml

Read the optional expression from the provided QDomElement.

writeXml

Save the optional expression to the provided QDomElement.

readXml(self, element: QDomElement)

Read the optional expression from the provided QDomElement.

New in version 2.18.

Parameters

element (QDomElement) –

writeXml(self, element: QDomElement)

Save the optional expression to the provided QDomElement.

The caller is responsible to pass an empty QDomElement and to append it to a parent element.

New in version 2.18.

Parameters

element (QDomElement) –