Class: QgsPropertyCollection

A grouped map of multiple QgsProperty objects, each referenced by a integer key value.

Properties within a collection are referenced by an integer key. This is done to avoid the cost of string creation and comparisons which would be required by a string key. The intended use case is that a context specific enum is cast to int and used for the key value. Examples of such enums are :

See also

QgsLayoutObject.DataDefinedProperty()

See also

QgsSymbolLayer.Property()

See also

QgsPalLabeling.Property()

See also

QgsAbstract3DSymbol.Property()

See also

QgsDiagramLayerSettings.Property()

See also

QgsPalLayerSettings.Property()

See also

QgsWidgetWrapper.Property()

Class Hierarchy

Inheritance diagram of qgis.core.QgsPropertyCollection

Base classes

QgsAbstractPropertyCollection

Abstract base class for QgsPropertyCollection like objects.

Methods

count

Returns the number of properties contained within the collection.

property

Returns a reference to a matching property from the collection, if one exists.

setProperty

Adds a property to the collection and takes ownership of it.

class qgis.core.QgsPropertyCollection[source]

Bases: QgsAbstractPropertyCollection

__init__(name: str | None = '')

Constructor for QgsPropertyCollection

Parameters:

name (Optional[str] = '') – collection name

__init__(other: QgsPropertyCollection)
Parameters:

other (QgsPropertyCollection)

count(self) int[source]

Returns the number of properties contained within the collection.

Return type:

int

property(self, key: int) QgsProperty

Returns a reference to a matching property from the collection, if one exists.

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

hasProperty()

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

Adds a property to the collection and takes ownership of it.

Parameters:
  • key (int) – integer key for property. Any existing property with the same key will be removed and replaced by this property. The intended use case is that a context specific enum is cast to int and used for the key value.

  • property (QgsProperty) – property to add. Ownership is transferred to the collection. Setting an invalid property will remove the property from the collection.

setProperty(self, key: int, value: Any)[source]

Convenience method, creates a QgsStaticProperty and stores it within the collection.

Parameters:
  • key (int) – integer key for property. Any existing property with the same key will be deleted and replaced by this property. The intended use case is that a context specific enum is cast to int and used for the key value.

  • value (Any) – static value for property