Class: QgsObjectCustomProperties

class qgis.core.QgsObjectCustomProperties

Bases: sip.wrapper

Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML in verbatim <customproperties> endverbatim element.

New in version 2.4.

QgsObjectCustomProperties() Constructor for QgsObjectCustomProperties.

QgsObjectCustomProperties(QgsObjectCustomProperties)

Methods

contains

Returns True if the properties contains a key with the specified name.

keys

Returns a list of all stored keys.

readXml

Read store contents from an XML node.

remove

Removes a key (entry) from the store.

setValue

Add an entry to the store with the specified key.

value

Returns the value for the given key.

writeXml

Writes the store contents to an XML node.

contains(self, key: str)bool

Returns True if the properties contains a key with the specified name.

New in version 3.14.

Parameters

key (str) –

Return type

bool

keys(self)List[str]

Returns a list of all stored keys.

Return type

List[str]

readXml(self, parentNode: QDomNode, keyStartsWith: str = '')

Read store contents from an XML node.

Parameters
  • parentNode (QDomNode) – node to read from

  • keyStartsWith (str = '') – reads only properties starting with the specified string (or all if the string is empty)

See also

writeXml()

remove(self, key: str)

Removes a key (entry) from the store.

Parameters

key (str) –

setValue(self, key: str, value: Any)

Add an entry to the store with the specified key.

If an entry with the same key exists already, it will be overwritten.

Parameters
  • key (str) –

  • value (Any) –

value(self, key: str, defaultValue: Any = None)Any

Returns the value for the given key.

If the key is not present in the properties, the defaultValue will be returned.

Parameters
  • key (str) –

  • defaultValue (Any = None) –

Return type

Any

writeXml(self, parentNode: QDomNode, doc: QDomDocument)

Writes the store contents to an XML node.

See also

readXml()

Parameters
  • parentNode (QDomNode) –

  • doc (QDomDocument) –