Subgroup: Property
Class: QgsPropertyCollection¶
-
class
qgis.core.
QgsPropertyCollection
¶ Bases:
qgis._core.QgsAbstractPropertyCollection
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
name
Returns the descriptive name of the property collection. prepare
property
Returns a reference to a matching property from the collection, if one exists. propertyKeys
readXml
Reads property collection state from an XML element. referencedFields
setName
Sets the descriptive name for the property collection. setProperty
Adds a property to the collection and takes ownership of it. toVariant
value
valueAsBool
Calculates the current value of the property with the specified key and interprets it as an boolean. valueAsColor
Calculates the current value of the property with the specified key and interprets it as a color. valueAsDouble
Calculates the current value of the property with the specified key and interprets it as a double. valueAsInt
Calculates the current value of the property with the specified key and interprets it as an integer. valueAsString
Calculates the current value of the property with the specified key and interprets it as a string. writeXml
Writes the current state of the property collection into an XML element 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
-
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. :param 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) Convience 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. :param value: static value for property
-
toVariant
(self, definitions: object) → Any¶
-
value
(self, key: int, context: QgsExpressionContext, defaultValue: Any = None) → Any¶
-