Subgroup: Abstract
Class: QgsAbstractPropertyCollection¶
-
class
qgis.core.
QgsAbstractPropertyCollection
(name: str = '')¶ Bases:
sip.wrapper
Constructor for QgsAbstractPropertyCollection. The name parameter should be set to a descriptive name for the collection.
QgsAbstractPropertyCollection(QgsAbstractPropertyCollection)
Abstract base class for QgsPropertyCollection like objects.
New in version 3.0: Methods
clear
Removes all properties from the collection. 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
Returns true if the collection contains a property with the specified key. isActive
Returns true if the collection contains an active property with the specified key. loadVariant
Loads this property collection from a QVariantMap, wrapped in a QVariant. name
Returns the descriptive name of the property collection. prepare
Prepares the collection against a specified expression context. property
Returns a matching property from the collection, if one exists. propertyKeys
Returns a list of property keys contained within the collection. readXml
Reads property collection state from an XML element. referencedFields
Returns the set of any fields referenced by the active properties from the collection. setName
Sets the descriptive name for the property collection. toVariant
Saves this property collection to a QVariantMap, wrapped in a QVariant. value
Returns the calculated value of the property with the specified key from within the collection. 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 Signals
Attributes
-
clear
(self)¶ Removes all properties from the collection.
-
hasActiveProperties
(self) → bool¶ Returns true if the collection has any active properties, or false if all properties within the collection are deactivated.
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¶ Returns true if the collection contains a property with the specified key.
Parameters: key – integer key for property. The intended use case is that a context specific enum is cast to int and used for the key value. See also
-
isActive
(self, key: int) → bool¶ Returns true if the collection 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.
-
loadVariant
(self, configuration: Any, definitions: object) → bool¶ Loads this property collection from a QVariantMap, wrapped in a QVariant. You can use QgsXmlUtils.readVariant to save it to an XML document.
See also
-
prepare
(self, context: QgsExpressionContext = QgsExpressionContext()) → bool¶ Prepares the collection against a specified expression context. Calling prepare before evaluating the collection’s properties multiple times allows precalculation of expensive setup tasks such as parsing expressions. Returns true if preparation was successful.
-
property
(self, key: int) → QgsProperty¶ Returns 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¶ Returns a list of property keys contained within the collection.
-
readXml
(self, collectionElem: QDomElement, definitions: object) → bool¶ Reads property collection state from an XML element.
Parameters: - collectionElem – source DOM element for property collection’s state
- definitions – property definitions
See also
-
referencedFields
(self, context: QgsExpressionContext = QgsExpressionContext()) → Set[str]¶ Returns the set of any fields referenced by the active properties from the collection.
Parameters: context – expression context the properties will be evaluated against.
-
toVariant
(self, definitions: object) → Any¶ Saves this property collection to a QVariantMap, wrapped in a QVariant. You can use QgsXmlUtils.writeVariant to save it to an XML document.
See also
-
value
(self, key: int, context: QgsExpressionContext, defaultValue: Any = None) → Any¶ Returns the calculated value of the property with the specified key from within the collection.
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.
- context – expression context to evaluate property against
- 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
See also
See also
See also
See also
See also
-
valueAsBool
(self, key: int, context: QgsExpressionContext, defaultValue: bool = False) → Tuple[bool, bool]¶ Calculates the current value of the property with the specified key and interprets it as an boolean.
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.
- context – QgsExpressionContext to evaluate the property for.
- defaultValue – default boolean to return if the property cannot be calculated as a boolean
- ok – if specified, will be set to true if conversion was successful
Returns: value parsed to bool
See also
See also
See also
See also
See also
-
valueAsColor
(self, key: int, context: QgsExpressionContext, defaultColor: Union[QColor, Qt.GlobalColor, QGradient] = QColor()) → Tuple[QColor, bool]¶ Calculates the current value of the property with the specified key and interprets it as a color.
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.
- context – QgsExpressionContext to evaluate the property for.
- defaultColor – default color to return if the property cannot be calculated as a color
- ok – if specified, will be set to true if conversion was successful
Returns: value parsed to color
See also
See also
See also
See also
See also
-
valueAsDouble
(self, key: int, context: QgsExpressionContext, defaultValue: float = 0) → Tuple[float, bool]¶ Calculates the current value of the property with the specified key and interprets it as a double.
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.
- context – QgsExpressionContext to evaluate the property for.
- defaultValue – default double to return if the property cannot be calculated as a double
- ok – if specified, will be set to true if conversion was successful
Returns: value parsed to double
See also
See also
See also
See also
See also
-
valueAsInt
(self, key: int, context: QgsExpressionContext, defaultValue: int = 0) → Tuple[int, bool]¶ Calculates the current value of the property with the specified key and interprets it as an integer.
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.
- context – QgsExpressionContext to evaluate the property for.
- defaultValue – default integer to return if the property cannot be calculated as a integer
- ok – if specified, will be set to true if conversion was successful
Returns: value parsed to integer
See also
See also
See also
See also
See also
-
valueAsString
(self, key: int, context: QgsExpressionContext, defaultString: str = '') → Tuple[str, bool]¶ Calculates the current value of the property with the specified key and interprets it as a string.
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.
- context – QgsExpressionContext to evaluate the property for.
- defaultString – default string to return if the property cannot be calculated as a string
- ok – if specified, will be set to true if conversion was successful
Returns: value parsed to string
See also
See also
See also
See also
See also
-