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, pluginName: str, defaultValue: Any = None, description: str = ‘’) Constructor for
QgsSettingsEntry
. This constructor is intended to be used from plugins.The
key
argument specifies the key of the settings. ThepluginName
argument is inserted in the key after the section. Thedefault
value argument specifies the default value for the settings entry. Thedescription
argument specifies a description for the settings entry.QgsSettingsEntryBase(
QgsSettingsEntryBase
)Enums
Bases:
enum.IntEnum
Methods
Get settings default value.
Returns settings entry defining key.
Get the settings entry description.
Returns
True
if the settings is contained in the underlying QSettings.Returns
True
if a part of the settings key is built dynamically.Get settings entry key.
Returns
True
if the provided key match the settings entry.Removes the settings from the underlying QSettings.
Get settings section.
Set settings value.
Get the settings entry type.
Get settings value.
- class SettingsType(value)¶
Bases:
enum.IntEnum
Types of settings entries
Variant
: Generic variantString
: StringStringList
: List of stringsBool
: BooleanInteger
: IntegerDouble
: Double precision numerEnumFlag
: Enum or FlagColor
: Color
- Bool = 3¶
- Color = 7¶
- Double = 5¶
- EnumFlag = 6¶
- Integer = 4¶
- String = 1¶
- StringList = 2¶
- Variant = 0¶
- defaultValueAsVariant(self) Any ¶
Get 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 ¶
Get the settings entry description.
- Return type
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
- hasDynamicKey(self) bool ¶
Returns
True
if a part of the settings key is built dynamically.- Return type
bool
- key(self, dynamicKeyPart: str = '') str ¶
Get settings entry key.
The
dynamicKeyPart
argument specifies the dynamic part of the settings key.key(self, dynamicKeyPartList: Iterable[str]) -> str Get 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 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
- 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 ¶
Get settings section. The settings section of the parent group is returned if available.
- Return type
- setVariantValue(self, value: Any, dynamicKeyPart: str = '') bool ¶
Set settings value.
The
value
to set. ThedynamicKeyPart
argument specifies the dynamic part of the settings key.setVariantValue(self, value: Any, dynamicKeyPartList: Iterable[str]) -> bool Set settings value.
The
value
to set. ThedynamicKeyParts
argument specifies the list of dynamic parts of the settings key.- Parameters
value (Any) –
dynamicKeyPart (str = '') –
- Return type
bool
- settingsType(self) QgsSettingsEntryBase.SettingsType ¶
Get the settings entry type.
- Return type
- valueAsVariant(self, dynamicKeyPart: str = '', useDefaultValueOverride: bool = False, defaultValueOverride: Any = None) Any ¶
Get settings value.
The
dynamicKeyPart
argument specifies the dynamic part of the settings key. TheuseDefaultValueOverride
argument specifies if defaultValueOverride should be used. ThedefaultValueOverride
argument if valid is used instead of the normal default value.valueAsVariant(self, dynamicKeyPartList: Iterable[str], useDefaultValueOverride: bool = False, defaultValueOverride: Any = None) -> Any Get settings value.
The
dynamicKeyParts
argument specifies the list of dynamic parts of the settings key. TheuseDefaultValueOverride
argument specifies if defaultValueOverride should be used. ThedefaultValueOverride
argument if valid is used instead of the normal default value.- Parameters
dynamicKeyPart (str = '') –
useDefaultValueOverride (bool = False) –
defaultValueOverride (Any = None) –
- Return type
Any