|What's Next||Using KConfig XT|
This tutorial looks at the KDE configuration data system, starting with an overview of the design fundamentals from an application developer's point of view. It then looks at the classes relevant to application development one by one before moving on to kiosk (user and group profiles) integration.
KConfig is designed to abstract away the concept of actual storage and retrieval of configuration settings behind an API that allows easy fetching and setting of information. Where and in what format the data is stored is not relevant to an application using KConfig. This keeps all KDE applications consistent in their handling of configurations while alleviating each and every application author to build such a system on their own from scratch, which is can be a highly error prone exercise.
A KConfig object represents a single configuration object. Each configuration object is referenced by its unique name and may be actually read from multiple local or remote files or services. Each application has a default configuration object associated with it and there is also a global configuration object.
These configuration objects are broken down into a two level hierarchy: groups and keys. A configuration object can have any number of groups and each group can have one or more keys with associated values.
Values stored may be of any number of data types. They are stored and retreived as the objects themselves. For example, a QColor object is passed to a config object directly when storing a color value and when retreived a QColor object is returned. Applications themselves therefore generally do not have to perform serialization and deserialization of objects themselves.
The KConfig class is used to access a given configuration object. There are a number of ways to create a config object:
// a plain old read/write config object
// a specific file in the filesystem // currently must be an INI style file KConfig fullPath("/etc/kderc");
// outside the standard config resource KConfig dataResource("data", "myapp/somefile");
// not merged with global values KConfig globalFree("localsrc", KConfig::NoGlobals);
// not merged with globals or the $KDEDIRS hierarchy KConfig simpleConfig("simplerc",
KConfig::NoGlobals | KConfig::LocalOnly);