Pages
API Documentation
On this page

KConfigBase Class

Interface to interact with configuration. More...

  • Header: #include <KConfigBase>
  • CMake: find_package(KF6 REQUIRED COMPONENTS Config)
    target_link_libraries(mytarget PRIVATE KF6::ConfigCore)
  • Inherited By: KConfig and KConfigGroup

List of all members, including inherited members

Public Types

Public Functions

Detailed Description

KConfigBase allows a component of an application to persists its configuration without the component knowing if it is storing the configuration into a top level KConfig or a KConfigGroup inside a KConfig instance.

Member Type Documentation

enum KConfigBase::AccessMode

Possible return values for accessMode().

Constant
KConfigBase::NoAccess 0
KConfigBase::ReadOnly 1
KConfigBase::ReadWrite 2

enum KConfigBase::WriteConfigFlag

flags KConfigBase::WriteConfigFlags

Flags to control write entry

Constant Value Description
KConfigBase::Persistent 0x01 Save this entry when saving the config object.
KConfigBase::Global 0x02 Save the entry to the global KDE config file instead of the application specific config file.
KConfigBase::Localized 0x04 Add the locale tag to the key when writing it.
KConfigBase::Notify (since Qt 5.51) `0x08 Persistent`
KConfigBase::Normal Persistent Save the entry to the application specific config file without a locale tag. This is the default.

The WriteConfigFlags type is a typedef for QFlags<WriteConfigFlag>. It stores an OR combination of WriteConfigFlag values.

See also KConfigGroup, KConfigWatcher, KConfigSkeletonItem::setWriteFlags()

Member Function Documentation

[pure virtual] KConfigBase::AccessMode KConfigBase::accessMode() const

Returns the access mode of the app-config object.

Possible return values are NoAccess (the application-specific config file could not be opened neither read-write nor read-only), ReadOnly (the application-specific config file is opened read-only, but not read-write) and ReadWrite (the application-specific config file is opened read-write).

void KConfigBase::deleteGroup(const QString &group, KConfigBase::WriteConfigFlags flags = Normal)

Delete group.

This marks group as deleted in the config object. This effectively removes any cascaded values from config files earlier in the stack.

KConfigGroup KConfigBase::group(const QString &group)

Returns an object for the named subgroup.

group the group to open. Pass an empty string here to the KConfig object to obtain a handle on the root group. Returns config group object for the given group name.

const KConfigGroup KConfigBase::group(const QString &group) const

Const overload for group(const QString&)

This is an overloaded function.

[pure virtual] QStringList KConfigBase::groupList() const

Returns a list of groups that are known about.

bool KConfigBase::hasGroup(const QString &group) const

Returns true if the specified group is known about.

group name of group to search for

bool KConfigBase::isGroupImmutable(const QString &group) const

Can changes be made to the entries in group?

group The group to check for immutability.

Returns false if the entries in group can be modified, otherwise true

[pure virtual] bool KConfigBase::isImmutable() const

Checks whether this configuration object can be modified.

[pure virtual] void KConfigBase::markAsClean()

Reset the dirty flags of all entries in the entry map, so the values will not be written to disk on a later call to sync().

[pure virtual] bool KConfigBase::sync()

Syncs the configuration object that this group belongs to.

Unrelated concurrent changes to the same file are merged and thus not overwritten. Note however, that this object is not automatically updated with those changes.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.