Class: QgsSettingsTreeNode

class qgis.core.QgsSettingsTreeNode

Bases: sip.wrapper

QgsSettingsTreeNode is a tree node for the settings registry to help organizing and introspecting the registry. It is either a root node, a normal node or a named list (to store a group of settings under a dynamic named key). The root node holds a pointer to a registry (might be null) to automatically register a settings entry on its creation when a parent is provided.

New in version 3.30:

Enums

Option

Bases: enum.IntEnum

Type

Bases: enum.IntEnum

Methods

childNode

Returns the existing child node if it exists at the given key

childSetting

Returns the existing child settings if it exists at the given key

childrenNodes

Returns the children nodes

childrenSettings

Returns the children settings

completeKey

Returns the complete key of the node (including its parents)

createChildNode

Creates a normal tree node It will return the existing child node if it exists at the given key

createNamedListNode

Creates a named list tree node.

key

Returns the key of the node (without its parents)

namedNodesCount

Returns the number of named nodes in the complete key

parent

Returns the parent of the node or None if it does not exists

registerChildSetting

Registers a child setting

type

Returns the type of node

unregisterChildNode

Unregisters the child tree node

unregisterChildSetting

Unregisters the child setting

Attributes

staticMetaObject

class Option(value)

Bases: enum.IntEnum

Options for named list nodes

  • NamedListSelectedItemSetting: Creates a setting to store which is the current item

NamedListSelectedItemSetting = 0
baseClass

alias of QgsSettingsTreeNode

class Options
class Options(Union[QgsSettingsTreeNode.Options, QgsSettingsTreeNode.Option])
class Options(QgsSettingsTreeNode.Options)

Bases: sip.wrapper

baseClass

alias of QgsSettingsTreeNode

class Type(value)

Bases: enum.IntEnum

Type of tree node

  • Root: Root Node

  • Standard: Normal Node

  • NamedList:

NamedList = 2
Root = 0
Standard = 1
baseClass

alias of QgsSettingsTreeNode

childNode(self, key: str) QgsSettingsTreeNode

Returns the existing child node if it exists at the given key

Parameters

key (str) –

Return type

QgsSettingsTreeNode

childSetting(self, key: str) QgsSettingsEntryBase

Returns the existing child settings if it exists at the given key

Parameters

key (str) –

Return type

QgsSettingsEntryBase

childrenNodes(self) List[QgsSettingsTreeNode]

Returns the children nodes

Return type

List[QgsSettingsTreeNode]

childrenSettings(self) List[QgsSettingsEntryBase]

Returns the children settings

Return type

List[QgsSettingsEntryBase]

completeKey(self) str

Returns the complete key of the node (including its parents)

Return type

str

createChildNode(self, key: str) QgsSettingsTreeNode

Creates a normal tree node It will return the existing child node if it exists at the given key

Raises

QgsSettingsException – if a setting exists with the same key

Parameters

key (str) –

Return type

QgsSettingsTreeNode

createNamedListNode(self, key: str, options: Union[QgsSettingsTreeNode.Options, QgsSettingsTreeNode.Option] = QgsSettingsTreeNode.Options()) QgsSettingsTreeNamedListNode

Creates a named list tree node. This is useful to register groups of settings for several named items (for instance credentials for several named services)

Parameters
Return type

QgsSettingsTreeNamedListNode

key(self) str

Returns the key of the node (without its parents)

Return type

str

namedNodesCount(self) int

Returns the number of named nodes in the complete key

Return type

int

parent(self) QgsSettingsTreeNode

Returns the parent of the node or None if it does not exists

Return type

QgsSettingsTreeNode

registerChildSetting(self, setting: QgsSettingsEntryBase, key: str)

Registers a child setting

Parameters
  • setting (QgsSettingsEntryBase) – the setting to register

  • key (str) – the key of the setting (not the complete key from its parents)

Note

Ownership of the setting is transferred

Note

The registration is automatically done when calling the setting’s constructor with the parent argument signature

Raises

QgsSettingsException – if a setting exists with the same key

staticMetaObject = <PyQt5.QtCore.QMetaObject object>
type(self) QgsSettingsTreeNode.Type

Returns the type of node

Return type

QgsSettingsTreeNode.Type

unregisterChildNode(self, node: QgsSettingsTreeNode)

Unregisters the child tree node

Parameters

node (QgsSettingsTreeNode) –

unregisterChildSetting(self, setting: QgsSettingsEntryBase, deleteSettingValues: bool = False, parentsNamedItems: Iterable[str] = [])

Unregisters the child setting

Parameters
  • setting (QgsSettingsEntryBase) – the setting to unregister

  • deleteSettingValues (bool = False) – if True, the values of the settings will also be deleted

  • parentsNamedItems (Iterable[str] = []) – the list of named items in the parent named list (if any)