Class: QgsProjectProperty¶
An abstract base class for QGIS project property hierarchys.
Each sub-class is either a QgsProjectPropertyKey
or
QgsProjectPropertyValue
. QgsProjectPropertyKey
can contain either QgsProjectPropertyKey
or
QgsProjectPropertyValues
, thus describing an hierarchy.
QgsProjectPropertyValues
are always graph leaves.
Note
This class is used internally by QgsProject
. It’s generally recommended that the methods in
QgsProject
are used to modify project properties rather than using these low-level classes.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: dump()
, isKey()
, isLeaf()
, isValue()
, readXml()
, value()
, writeXml()
Class Hierarchy¶
Subclasses¶
Project property key node. |
|
Project property value node, contains a |
Abstract Methods
Dumps out the keys and values |
|
Returns |
|
Returns |
|
Returns |
|
Restores the property hierarchy from a specified DOM node. |
|
Returns the node's value. |
|
Writes the property hierarchy to a specified DOM element. |
- class qgis.core.QgsProjectProperty[source]¶
Bases:
object
- abstract dump(self, tabs: int = 0)[source]¶
Dumps out the keys and values
- Parameters:
tabs (int = 0) – is number of tabs to print; used for pretty-printing hierarchy
- abstract isKey(self) bool [source]¶
Returns
True
if the property is aQgsProjectPropertyKey
.See also
See also
- Return type:
bool
- abstract isLeaf(self) bool [source]¶
Returns
True
if property is a leaf node.A leaf node is a key node that has either no value or only a single value. A non-leaf node would be a key node with key sub-nodes.
This is used for
entryList()
andsubkeyList()
implementation.- Return type:
bool
- abstract isValue(self) bool [source]¶
Returns
True
if the property is aQgsProjectPropertyValue
.See also
See also
- Return type:
bool
- abstract readXml(self, keyNode: QDomNode) bool [source]¶
Restores the property hierarchy from a specified DOM node.
Used for restoring properties from project file
- Parameters:
keyNode (QDomNode)
- Return type:
bool
- abstract value(self) Any [source]¶
Returns the node’s value.
For
QgsProjectPropertyValue
nodes, this is straightforward – just return the embedded QVariant, _value. ForQgsProjectPropertyKey
, this means returning theQgsProjectPropertyValue
_value that is keyed by its name, if it exists; i.e.,QgsProjectPropertyKey
“foo” will return the property value mapped to its name, “foo”, in its QHash of QProperties.- Return type:
Any
- abstract writeXml(self, nodeName: str | None, element: QDomElement, document: QDomDocument) bool [source]¶
Writes the property hierarchy to a specified DOM element.
Used for saving properties to project file.
- Parameters:
nodeName (Optional[str]) – the tag name associated with this element
element (QDomElement) – the parent (or encompassing) property element
document (QDomDocument) – the overall project file Dom document
- Return type:
bool