Class: QgsConditionalLayerStyles

Holds conditional style information for a layer.

This includes field styles and full row styles.

Class Hierarchy

Inheritance diagram of qgis.core.QgsConditionalLayerStyles

Base classes

QObject

Methods

constraintFailureStyles

Returns a style associated to a constraint failure.

fieldStyles

Returns the conditional styles set for the field with matching fieldName.

readXml

Reads the condition styles state from a DOM node.

rowStyles

Returns a list of row styles associated with the layer.

rulesNeedGeometry

Returns True if at least one rule needs geometry.

setFieldStyles

Set the conditional styles for a field, with the specified fieldName.

setRowStyles

Sets the conditional styles that apply to full rows of data in the attribute table.

writeXml

Writes the condition styles state to a DOM node.

Signals

changed

Emitted when the conditional styles are changed.

class qgis.core.QgsConditionalLayerStyles[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructor for QgsConditionalLayerStyles, with the specified parent object.

Parameters:

parent (Optional[QObject] = None)

signal changed[source]

Emitted when the conditional styles are changed.

Added in version 3.10.

constraintFailureStyles(self, strength: QgsFieldConstraints.ConstraintStrength) QgsConditionalStyle[source]

Returns a style associated to a constraint failure.

Parameters:

strength (QgsFieldConstraints.ConstraintStrength) – the type of constraint

Added in version 3.30.

Return type:

QgsConditionalStyle

fieldStyles(self, fieldName: str | None) List[QgsConditionalStyle]

Returns the conditional styles set for the field with matching fieldName.

See also

setFieldStyles()

Parameters:

fieldName (Optional[str])

Return type:

List[QgsConditionalStyle]

readXml(self, node: QDomNode, context: QgsReadWriteContext) bool[source]

Reads the condition styles state from a DOM node.

See also

writeXml()

Parameters:
Return type:

bool

rowStyles(self) List[QgsConditionalStyle][source]

Returns a list of row styles associated with the layer.

See also

setRowStyles()

Return type:

List[QgsConditionalStyle]

rulesNeedGeometry(self) bool[source]

Returns True if at least one rule needs geometry.

Added in version 3.26.3.

Return type:

bool

setFieldStyles(self, fieldName: str | None, styles: Iterable[QgsConditionalStyle])[source]

Set the conditional styles for a field, with the specified fieldName.

The field value is inserted into a ‘value’ variable to conduct expression checks.

See also

fieldStyles()

Parameters:
setRowStyles(self, styles: Iterable[QgsConditionalStyle])[source]

Sets the conditional styles that apply to full rows of data in the attribute table. Each row will check be checked against each rule.

See also

rowStyles()

Parameters:

styles (Iterable[QgsConditionalStyle])

writeXml(self, node: QDomNode, doc: QDomDocument, context: QgsReadWriteContext) bool[source]

Writes the condition styles state to a DOM node.

See also

readXml()

Parameters:
Return type:

bool