Class: QgsOptionalExpression

class qgis.core.QgsOptionalExpression

Bases: qgis._core.QgsOptionalQgsExpressionBase

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)

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: Methods

readXml Read the optional expression from the provided QDomElement.
writeXml Save the optional expression to the provided QDomElement.

Signals

Attributes

readXml(self, element: QDomElement)

Read the optional expression from the provided QDomElement.

New in version 2.18.

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.