Class: QgsProjectPropertyKey

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

Bases: QgsProjectProperty

Create a new QgsProjectPropertyKey with the specified identifier.

QgsProjectPropertyKey(QgsProjectPropertyKey)

Project property key node.

Can, itself, contain QgsProjectPropertyKey and QgsProjectPropertyValues.

The internal QHash, mProperties, maps key names to their respective QgsProjectPropertyValue or next QgsProjectPropertyKey in the key name sequence. The key with the current name should contain its QgsProjectPropertyValue.

E.g., given the key sequence “/foo/bar”, “foo” will have a corresponding QgsProjectPropertyKey with a name “foo”. It will contain an element in its mProperties that maps to “bar”, which is another QgsProjectPropertyKey. The “bar” QgsProjectPropertyKey will, in turn, have an element that maps to itself, i.e. “bar”, that will contain a QgsProjectPropertyValue.

New in version 3.0.

Parameters

name

addKey(self, keyName: str) → QgsProjectPropertyKey

Adds the specified property key as a sub-key.

Parameters

keyName (str) –

Return type

QgsProjectPropertyKey

clear(self)

Resets the property to a default, empty state.

clearKeys(self)

Deletes any sub-nodes from the property.

count(self) → int

Returns the number of sub-keys contained by this property.

Return type

int

dump(self, tabs: int = 0)
Parameters

tabs (int = 0) –

entryList(self, entries: Iterable[str])

Returns any sub-keys contained by this property that do not contain other keys.

See also

subkeyList()

Parameters

entries (Iterable[str]) –

find(self, propertyName: str) → QgsProjectProperty

Attempts to find a property with a matching sub-key name.

Parameters

propertyName (str) –

Return type

QgsProjectProperty

isEmpty(self) → bool

Returns True if this property contains no sub-keys.

Return type

bool

isKey(self) → bool
Return type

bool

isLeaf(self) → bool
Return type

bool

isValue(self) → bool
Return type

bool

name(self) → str

The name of the property is used as identifier.

See also

setName()

Return type

str

readXml(self, keyNode: QDomNode) → bool
Parameters

keyNode (QDomNode) –

Return type

bool

removeKey(self, keyName: str)

Removes the specified key.

Parameters

keyName (str) –

setName(self, name: str)

The name of the property is used as identifier.

See also

name()

New in version 3.0.

Parameters

name (str) –

setValue(self, name: str, value: Any) → QgsProjectPropertyValue

Sets the value associated with this key.

Parameters
  • name (str) – is the key name

  • value (Any) – is the value to set

Return type

QgsProjectPropertyValue

Returns

pointer to property value

setValue(self, value: Any) -> QgsProjectPropertyValue Set the value associated with this key

Note

that the single value node associated with each key is always stored keyed by the current key name

subkeyList(self, entries: Iterable[str])

Returns any sub-keys contained by this property which themselves contain other keys.

See also

entryList()

Parameters

entries (Iterable[str]) –

value(self) → Any

If this key has a value, it will be stored by its name in its properties

Return type

Any

writeXml(self, nodeName: str, element: QDomElement, document: QDomDocument) → bool
Parameters
  • nodeName (str) –

  • element (QDomElement) –

  • document (QDomDocument) –

Return type

bool