Class: 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.

Class Hierarchy

Inheritance diagram of qgis.core.QgsOptionalExpression

Base classes

QgsOptionalQgsExpressionBase

A container for other classes and adds an additional enabled/disabled flag.

Methods

readXml

Read the optional expression from the provided QDomElement.

writeXml

Save the optional expression to the provided QDomElement.

class qgis.core.QgsOptionalExpression[source]

Bases: QgsOptionalQgsExpressionBase

__init__()

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

__init__(expression: QgsExpression)

Construct an optional expression with the provided expression. It will be enabled.

Parameters:

expression (QgsExpression)

__init__(expression: QgsExpression, enabled: bool)

Construct an optional expression with the provided expression and enabled state.

Parameters:
__init__(a0: QgsOptionalExpression)
Parameters:

a0 (QgsOptionalExpression)

readXml(self, element: QDomElement)[source]

Read the optional expression from the provided QDomElement.

Parameters:

element (QDomElement)

writeXml(self, element: QDomElement)[source]

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.

Parameters:

element (QDomElement)