Class: QgsSettingsEntryBase

class qgis.core.QgsSettingsEntryBase

Bases: sip.wrapper

Represent settings entry and provides methods for reading and writing settings values. Different subclasses are provided for different settings types with metainformations to validate set values and provide more accurate settings description for the gui.

New in version 3.20.

QgsSettingsEntryBase(key: str, section: str, defaultValue: Any = None, description: str = ‘’, options: Union[Qgis.SettingsOptions, Qgis.SettingsOption] = Qgis.SettingsOptions()) Constructor for QgsSettingsEntryBase.

The key argument specifies the key of the settings. The section argument specifies the section. The defaultValue argument specifies the default value for the settings entry. The description argument specifies a description for the settings entry. The options argument specifies the options for the settings entry.

QgsSettingsEntryBase(QgsSettingsEntryBase)

Enums

SettingsType

Bases: enum.IntEnum

Methods

defaultValueAsVariant

Returns settings default value.

definitionKey

Returns settings entry defining key.

description

Returns the settings entry description.

dynamicKeyPartToList

Transforms a dynamic key part string to list

exists

Returns True if the settings is contained in the underlying QSettings.

formerValueAsVariant

Returns the former value of the settings if it has been enabled in the options.

hasDynamicKey

Returns True if a part of the settings key is built dynamically.

key

Returns settings entry key.

keyIsValid

Returns True if the provided key match the settings entry.

options

Returns the settings options

remove

Removes the settings from the underlying QSettings.

section

Returns settings section.

setVariantValue

Set settings value.

setVariantValuePrivate

Sets the settings value with a variant value.

settingsType

Returns the settings entry type.

valueAsVariant

Returns settings value with the dynamicKeyPart argument specifying the dynamic part of the settings key.

valueAsVariantWithDefaultOverride

Returns settings value with a defaultValueOverride

class SettingsType(value)

Bases: enum.IntEnum

Types of settings entries

New in version 3.26.

  • Variant: Generic variant

  • String: String

  • StringList: List of strings

  • Bool: Boolean

  • Integer: Integer

  • Double: Double precision number

  • EnumFlag: Enum or Flag

  • Color: Color

baseClass

alias of Qgis

defaultValueAsVariant(self) Any

Returns settings default value.

Return type:

Any

definitionKey(self) str

Returns settings entry defining key. For dynamic settings it return the key with the placeholder for dynamic part included. For non-dynamic settings returns the same as key().

Return type:

str

description(self) str

Returns the settings entry description.

Return type:

str

dynamicKeyPartToList(dynamicKeyPart: str) List[str]

Transforms a dynamic key part string to list

New in version 3.26.

Parameters:

dynamicKeyPart (str) –

Return type:

List[str]

exists(self, dynamicKeyPart: str = '') bool

Returns True if the settings is contained in the underlying QSettings.

The dynamicKeyPart argument specifies the dynamic part of the settings key.

exists(self, dynamicKeyPartList: Iterable[str]) -> bool Returns True if the settings is contained in the underlying QSettings.

The dynamicKeyParts argument specifies the list of dynamic parts of the settings key.

Parameters:

dynamicKeyPart (str = '') –

Return type:

bool

formerValueAsVariant(self, dynamicKeyPart: str) Any

Returns the former value of the settings if it has been enabled in the options. Returns the current value (or default) if there is no former value.

New in version 3.26.

formerValueAsVariant(self, dynamicKeyPartList: Iterable[str]) -> Any Returns the former value of the settings if it has been enabled in the options Returns the current value (or default) if there is no former value.

New in version 3.26.

Parameters:

dynamicKeyPart (str) –

Return type:

Any

hasDynamicKey(self) bool

Returns True if a part of the settings key is built dynamically.

Return type:

bool

key(self, dynamicKeyPart: str = '') str

Returns settings entry key.

The dynamicKeyPart argument specifies the dynamic part of the settings key.

key(self, dynamicKeyPartList: Iterable[str]) -> str Returns settings entry key.

The dynamicKeyParts argument specifies the list of dynamic parts of the settings key.

Parameters:

dynamicKeyPart (str = '') –

Return type:

str

keyIsValid(self, key: str) bool

Returns True if the provided key match the settings entry.

This is useful for settings with dynamic keys. For example this permits one to check that the settings key “NewsFeed/httpsfeedqgisorg/27/content” is valid for the settings entry defined with the key “NewsFeed/%1/%2/content”

The key to check

Parameters:

key (str) –

Return type:

bool

options(self) Qgis.SettingsOptions

Returns the settings options

New in version 3.26.

Return type:

Qgis.SettingsOptions

remove(self, dynamicKeyPart: str = '')

Removes the settings from the underlying QSettings.

The dynamicKeyPart argument specifies the dynamic part of the settings key.

remove(self, dynamicKeyPartList: Iterable[str]) Removes the settings from the underlying QSettings.

The dynamicKeyParts argument specifies the list of dynamic parts of the settings key.

Parameters:

dynamicKeyPart (str = '') –

section(self) QgsSettings.Section

Returns settings section. The settings section of the parent group is returned if available.

Deprecated since version QGIS: 3.26 the key is entirely self-defined

Return type:

QgsSettings.Section

setVariantValue(self, value: Any, dynamicKeyPart: str = '') bool

Set settings value.

The value to set. The dynamicKeyPart argument specifies the dynamic part of the settings key.

Deprecated since version QGIS: 3.26 use setVariantValuePrivate or an implementation setValue instead

setVariantValue(self, value: Any, dynamicKeyPartList: Iterable[str]) -> bool Set settings value.

The value to set. The dynamicKeyParts argument specifies the list of dynamic parts of the settings key.

Deprecated since version QGIS: 3.26 use setVariantValuePrivate or an implementation setValue instead

Parameters:
  • value (Any) –

  • dynamicKeyPart (str = '') –

Return type:

bool

setVariantValuePrivate(self, value: Any, dynamicKeyPartList: Iterable[str] = []) bool

Sets the settings value with a variant value. This should be called from any implementation as it takes care of actually calling QSettings

New in version 3.26.

Parameters:
  • value (Any) –

  • dynamicKeyPartList (Iterable[str] = []) –

Return type:

bool

settingsType(self) Qgis.SettingsType

Returns the settings entry type.

Return type:

Qgis.SettingsType

valueAsVariant(self, dynamicKeyPart: str = '') Any

Returns settings value with the dynamicKeyPart argument specifying the dynamic part of the settings key.

valueAsVariant(self, dynamicKeyPartList: Iterable[str]) -> Any Returns settings value with the dynamicKeyPart argument specifying the dynamic part of the settings key.

valueAsVariant(self, dynamicKeyPart: str, useDefaultValueOverride: bool, defaultValueOverride: Any) -> Any Returns settings value with an optional default value override

Deprecated since version QGIS: 3.26 use valueAsVariantWithDefaultOverride instead

valueAsVariant(self, dynamicKeyPartList: Iterable[str], useDefaultValueOverride: bool, defaultValueOverride: Any) -> Any Returns settings value with an optional default value override

Deprecated since version QGIS: 3.26 use valueAsVariantWithDefaultOverride instead

Parameters:

dynamicKeyPart (str = '') –

Return type:

Any

valueAsVariantWithDefaultOverride(self, defaultValueOverride: Any, dynamicKeyPart: str = '') Any

Returns settings value with a defaultValueOverride

New in version 3.26.

valueAsVariantWithDefaultOverride(self, defaultValueOverride: Any, dynamicKeyPartList: Iterable[str]) -> Any Returns settings value.

The dynamicKeyPartList argument specifies the list of dynamic parts of the settings key. The defaultValueOverride argument if valid is used instead of the normal default value.

New in version 3.26.

Parameters:
  • defaultValueOverride (Any) –

  • dynamicKeyPart (str = '') –

Return type:

Any