class KConfigSkeleton


Table of contents
Modules
kdeui Classes
All Classes
Module kdeui
Namespace global
Class KConfigSkeleton
Inherits QObject

< Stores the value for this item < The default value for this item Class for handling preferences settings for an application. Author Cornelius Schumacher

See also KConfigSkeletonItem

This class provides an interface to preferences settings. Preferences items can be registered by the addItem() function corresponding to the data type of the seetting. KConfigSkeleton then handles reading and writing of config files and setting of default values.

Normally you will subclass KConfigSkeleton, add data members for the preferences settings and register the members in the constructor of the subclass.

Example:

class MyPrefs : public KConfigSkeleton
{
public:
MyPrefs()
{
setCurrentGroup("MyGroup");
addItemBool("MySetting1",mMyBool,false);
addItemColor("MySetting2",mMyColor,QColor(1,2,3));

setCurrentGroup("MyOtherGroup"); addItemFont("MySetting3",mMyFont,QFont("helvetica",12)); }

bool mMyBool; QColor mMyColor; QFont mMyFont; }

It might be convenient in many cases to make this subclass of KConfigSkeleton a singleton for global access from all over the application without passing references to the KConfigSkeleton object around.

You can write the data to the configuration file by calling writeConfig() and read the data from the configuration file by calling readConfig(). If you want to watch for config changes, use configChanged() signal.

If you have items, which are not covered by the existing addItem() functions you can add customized code for reading, writing and default setting by implementing the functions usrUseDefaults(), usrReadConfig() and usrWriteConfig().

Internally preferences settings are stored in instances of subclasses of KConfigSkeletonItem. You can also add KConfigSkeletonItem subclasses for your own types and call the generic addItem() to register them.

In many cases you don't have to write the specific KConfigSkeleton subclasses yourself, but you can use kconfig_compiler to automatically generate the C++ code from an XML description of the configuration options.



methods