KConfigSkeleton Class

Class for handling preferences settings for an application. More...

Header: #include <KConfigSkeleton>
CMake: find_package(KF6 REQUIRED COMPONENTS Config)
target_link_libraries(mytarget PRIVATE KF6::ConfigGui)
Inherits: KCoreConfigSkeleton
Inherited By:

KConfigLoader

Public Types

class ItemColor
class ItemFont

Public Functions

KConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = nullptr)
KConfigSkeleton(const QString &configname = QString(), QObject *parent = nullptr)
(since 6.23) KConfigSkeleton(std::unique_ptr<KConfig> config, KCoreConfigSkeleton::DisambiguateConstructor value, QObject *parent = nullptr)
KConfigSkeleton::ItemColor *addItemColor(const QString &name, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128), const QString &key = QString())
KConfigSkeleton::ItemFont *addItemFont(const QString &name, QFont &reference, const QFont &defaultValue = QFont(), const QString &key = QString())

Detailed Description

This class extends KCoreConfigSkeleton with support for GUI types.

Member Function Documentation

[explicit] KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = nullptr)

Constructs a configuration skeleton with the given config object as a child of parent.

[explicit] KConfigSkeleton::KConfigSkeleton(const QString &configname = QString(), QObject *parent = nullptr)

Constructs a configuration skeleton with the given configname as a child of parent.

If no name is given, the default config as returned by KSharedConfig::openConfig() is used.

[explicit, since 6.23] KConfigSkeleton::KConfigSkeleton(std::unique_ptr<KConfig> config, KCoreConfigSkeleton::DisambiguateConstructor value, QObject *parent = nullptr)

Constructs a configuration skeleton with a given config object as a child of parent.

The value must be KCoreConfigSkeleton::IsStdUniqPtr.

The use of this single-valued enum is mandatory to disambiguate with the other constructor that may otherwise be ambiguous in case of default nullptr KCoreConfigSkeleton(KSharedConfig::Ptr(nullptr)) or KCoreConfigSkeleton(std::unique_ptr<KConfig> (nullptr)) with parent = nullptr.

This function was introduced in 6.23.

See also KCoreConfigSkeleton::DisambiguateConstructor.

KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128), const QString &key = QString())

Registers a QColor item with the given name, the initial value reference to hold in the item, and the defaultValue for the item used when the config file does not yet contain the key of this item.

The reference should be a pointer to the variable that is set by read() calls and read by save() calls.

If key is a null string, name is used as key.

KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, const QFont &defaultValue = QFont(), const QString &key = QString())

Registers a QFont item with the given name, the initial value reference to hold in the item, and the defaultValue for the item used when the config file does not yet contain the key of this item.

The reference should be a pointer to the variable that is set by read() calls and read by save() calls.

If key is a null string, name is used as key.