Subgroup: Property

Class: QgsPropertyCollection

class qgis.core.QgsPropertyCollection(name: str = '')

Bases: qgis._core.QgsAbstractPropertyCollection

Constructor for QgsPropertyCollection

Parameters:name – collection name

QgsPropertyCollection(other: QgsPropertyCollection) Copy constructor.

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.

New in version 3.0: Methods

clear
count Returns the number of properties contained within the collection.
hasActiveProperties
hasDynamicProperties
hasProperty
isActive
loadVariant
prepare
property Returns a reference to a matching property from the collection, if one exists.
propertyKeys
referencedFields
setProperty Adds a property to the collection and takes ownership of it.
toVariant
value

Signals

Attributes

clear(self)
count(self) → int

Returns the number of properties contained within the collection.

hasActiveProperties(self) → bool
hasDynamicProperties(self) → bool
hasProperty(self, key: int) → bool
isActive(self, key: int) → bool
loadVariant(self, configuration: Any, definitions: object) → bool
prepare(self, context: QgsExpressionContext = QgsExpressionContext()) → bool
property(self, key: int) → QgsProperty

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

Parameters:key – 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.
Returns:matching property, or null if no matching, active property found.

See also

hasProperty()

propertyKeys(self) → object
referencedFields(self, context: QgsExpressionContext = QgsExpressionContext()) → Set[str]
setProperty(self, key: int, property: QgsProperty)

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

Parameters:
  • key – 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 – 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) Convenience method, creates a QgsStaticProperty and stores it within the collection.

Parameters:
  • key – 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 – static value for property
toVariant(self, definitions: object) → Any
value(self, key: int, context: QgsExpressionContext, defaultValue: Any = None) → Any