Subgroup: Property
Class: QgsPropertyCollectionStack¶
-
class
qgis.core.
QgsPropertyCollectionStack
¶ Bases:
qgis._core.QgsAbstractPropertyCollection
An ordered stack of QgsPropertyCollection containers, where collections added later to the stack will take priority over earlier collections.
New in version 3.0: 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. clear
Removes all collections 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. hasActiveProperties
Returns true if the collection has any active properties, or false if all properties within the collection are deactivated. hasDynamicProperties
Returns true if the collection has any active, non-static properties, or false if either all non-static properties within the collection are deactivated or if the collection only contains static properties. hasProperty
isActive
Returns true if the stack contains an active property with the specified key. loadVariant
name
Returns the descriptive name of the property collection. prepare
property
Returns the highest priority property with a matching key from within the stack. propertyKeys
readXml
Reads property collection state from an XML element. referencedFields
Returns the set of any fields referenced by the active properties from the stack. setName
Sets the descriptive name for the property collection. toVariant
value
Returns the calculated value of the highest priority property with the specified key from within the stack. 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
-
appendCollection
(self, collection: QgsPropertyCollection)¶ 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 – collection to append. Ownership is transferred to the stack.
-
at
(self, index: int) → QgsPropertyCollection¶ Returns the collection at the corresponding index from the stack.
Parameters: index – position of collection, 0 based Returns: collection if one exists at the specified index
-
clear
(self)¶ Removes all collections from the stack.
-
collection
(self, name: str) → QgsPropertyCollection¶ Returns the first collection with a matching name from the stack.
Parameters: name – name of collection to find Returns: collection if one exists with the specified name
-
count
(self) → int¶ Returns the number of collections contained within the stack.
-
hasActiveProperties
(self) → bool¶ Returns true if the collection has any active properties, or false if all properties within the collection are deactivated.
See also
See also
-
hasDynamicProperties
(self) → bool¶ Returns true if the collection has any active, non-static properties, or false if either all non-static properties within the collection are deactivated or if the collection only contains static properties.
See also
-
hasProperty
(self, key: int) → bool¶
-
isActive
(self, key: int) → bool¶ Returns true if the stack contains an active property with the specified key.
Parameters: key – 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.
See also
-
loadVariant
(self, collection: Any, definitions: object) → bool¶
-
prepare
(self, context: QgsExpressionContext = QgsExpressionContext()) → bool¶
-
property
(self, key: int) → QgsProperty¶ Returns the highest priority property with a matching key from within the stack.
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
hasActiveProperty()
-
propertyKeys
(self) → object¶
-
referencedFields
(self, context: QgsExpressionContext = QgsExpressionContext()) → Set[str]¶ Returns the set of any fields referenced by the active properties from the stack.
Parameters: context – expression context the properties will be evaluated against.
-
toVariant
(self, definitions: object) → Any¶
-
value
(self, key: int, context: QgsExpressionContext, defaultValue: Any = None) → Any¶ Returns the calculated value of the highest priority property with the specified key from within the stack.
Parameters: key – 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. :param context: expression context to evaluate property against :param defaultValue: default value to return if no matching, active property found or if the property value cannot be calculated
Returns: calculated property value, or default value if property could not be evaluated
-