QgsOptionalExpression class

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.

Base classes

template<typename T>
class QgsOptional
QgsOptional is a container for other classes and adds an additional enabled/disabled flag.

Constructors, destructors, conversion operators

QgsOptionalExpression() defaulted
Construct a default optional expression.
QgsOptionalExpression(const QgsExpression& expression)
Construct an optional expression with the provided expression.
QgsOptionalExpression(const QgsExpression& expression, bool enabled)
Construct an optional expression with the provided expression and enabled state.

Public functions

void readXml(const QDomElement& element)
Read the optional expression from the provided QDomElement.
void writeXml(QDomElement& element)
Save the optional expression to the provided QDomElement.

Function documentation

QgsOptionalExpression::QgsOptionalExpression() defaulted

Construct a default optional expression.

It will be disabled and with an empty expression.

QgsOptionalExpression::QgsOptionalExpression(const QgsExpression& expression)

Construct an optional expression with the provided expression.

It will be enabled.

void QgsOptionalExpression::readXml(const QDomElement& element)

Read the optional expression from the provided QDomElement.

void QgsOptionalExpression::writeXml(QDomElement& element)

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.