Class: QgsObjectCustomProperties

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

class qgis.core.QgsObjectCustomProperties[source]

Bases: object

contains(self, key: str | None) bool[source]

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

Added in version 3.14.

Parameters:

key (Optional[str])

Return type:

bool

keys(self) List[str][source]

Returns a list of all stored keys.

Return type:

List[str]

readXml(self, parentNode: QDomNode, keyStartsWith: str | None = '')[source]

Read store contents from an XML node.

Parameters:
  • parentNode (QDomNode) – node to read from

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

See also

writeXml()

remove(self, key: str | None)[source]

Removes a key (entry) from the store.

Parameters:

key (Optional[str])

setValue(self, key: str | None, value: Any)[source]

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 (Optional[str])

  • value (Any)

value(self, key: str | None, defaultValue: Any = None) Any[source]

Returns the value for the given key.

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

Parameters:
  • key (Optional[str])

  • defaultValue (Any = None)

Return type:

Any

writeXml(self, parentNode: QDomNode, doc: QDomDocument)[source]

Writes the store contents to an XML node.

See also

readXml()

Parameters:
  • parentNode (QDomNode)

  • doc (QDomDocument)