Class: QgsPropertyCollectionStack

An ordered stack of QgsPropertyCollection containers, where collections added later to the stack will take priority over earlier collections.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: QgsAbstractPropertyCollection.clear()

Class Hierarchy

Inheritance diagram of qgis.core.QgsPropertyCollectionStack

Base classes

QgsAbstractPropertyCollection

Abstract base class for QgsPropertyCollection like objects.

Abstract Methods

clear

Removes all collections from the stack.

hasActiveProperties

Returns True if the collection has any active properties, or False if all properties within the collection are deactivated.

isActive

Returns True if the stack contains an active property with the specified key.

property

Returns the highest priority property with a matching key from within the stack.

referencedFields

Returns the set of any fields referenced by the active properties from the stack.

value

Returns the calculated value of the highest priority property with the specified key from within the stack.

Methods

appendCollection

Appends a collection to the end of the stack, and transfers ownership of the collection to the stack.

at

Returns the collection at the corresponding index from the stack.

collection

Returns the first collection with a matching name from the stack.

count

Returns the number of collections contained within the stack.

class qgis.core.QgsPropertyCollectionStack[source]

Bases: QgsAbstractPropertyCollection

appendCollection(self, collection: QgsPropertyCollection | None)[source]

Appends a collection to the end of the stack, and transfers ownership of the collection to the stack. Properties from the newly added collection will take priority over any existing properties with the same name.

Parameters:

collection (Optional[QgsPropertyCollection]) – collection to append. Ownership is transferred to the stack.

at(self, index: int) QgsPropertyCollection | None[source]

Returns the collection at the corresponding index from the stack.

Parameters:

index (int) – position of collection, 0 based

Return type:

Optional[QgsPropertyCollection]

Returns:

collection if one exists at the specified index

abstract clear(self)[source]

Removes all collections from the stack.

collection(self, name: str | None) QgsPropertyCollection | None[source]

Returns the first collection with a matching name from the stack.

Parameters:

name (Optional[str]) – name of collection to find

Return type:

Optional[QgsPropertyCollection]

Returns:

collection if one exists with the specified name

count(self) int[source]

Returns the number of collections contained within the stack.

Return type:

int

abstract hasActiveProperties(self) bool[source]

Returns True if the collection has any active properties, or False if all properties within the collection are deactivated.

See also

isActive()

See also

hasDynamicProperties()

Return type:

bool

abstract isActive(self, key: int) bool[source]

Returns True if the stack contains an active property with the specified key.

Parameters:

key (int) – integer key for property to test. The intended use case is that a context specific enum is cast to int and used for the key value.

Return type:

bool

abstract property(self, key: int) QgsProperty[source]

Returns the highest priority property with a matching key from within the stack.

Parameters:

key (int) – integer key for property to return. The intended use case is that a context specific enum is cast to int and used for the key value.

Return type:

QgsProperty

Returns:

matching property, or null if no matching, active property found.

See also

hasActiveProperty()

abstract referencedFields(self, context: QgsExpressionContext = QgsExpressionContext(), ignoreContext: bool = False) Set[str]

Returns the set of any fields referenced by the active properties from the stack.

Parameters:
  • context (QgsExpressionContext = QgsExpressionContext()) – expression context the properties will be evaluated against.

  • ignoreContext (bool = False) – This parameter has been added in QGIS 3.14. When set to True, even fields not set in context’s fields() will be reported - this is useful e.g. with vector tiles where the actual available field names may not be known beforehand.

Return type:

Set[str]

abstract value(self, key: int, context: QgsExpressionContext, defaultValue: Any = None) Any[source]

Returns the calculated value of the highest priority property with the specified key from within the stack.

Parameters:
  • key (int) – integer key for property to calculate. The intended use case is that a context specific enum is cast to int and used for the key value.

  • context (QgsExpressionContext) – expression context to evaluate property against

  • defaultValue (Any = None) – default value to return if no matching, active property found or if the property value cannot be calculated

Return type:

Any

Returns:

calculated property value, or default value if property could not be evaluated