How to load default settings using KConfig on kdelib?

I have a question about using KConfig. I can write and read settings in my .kde4 / share / config / _appname_rc configuration file like this

 KConfig basicconf;
 KConfigGroup conf = KConfigGroup(basicconf.group("Settings"));
 conf.writeEntry("filepath",QString("/path/"));
 basicconf.sync();

But I don’t understand how to use the “default” configuration file to read for the first time when I launch my application, or if the application settings need to be reset.

I prefer not to use KConfig XT because my project is tiny, and KConfigXT with kcfgc * files seems excessive.

Thank you in advance

0
source share
2 answers

The first is:

KConfigGroup conf = KConfigGroup (basicconf.group( "" ));

, imho, :

KConfigGroup conf (& basicconf, "" );

, "" "" . ...

; $PREFIX/share/config/, CMakeLists.txt:

install (FILES < > DESTINATION ${CONFIG_INSTALL_DIR})

KConfig ; .

KKonfigXT, , , , .. , CMakeLists.txt , , . TechBase.

+3

KGlobal:: config(), KConfig , . $KDEHOME/share/config.

KConfig XT ,

  • API YourSettings ; YourSettings:: setFilePath (), conf.writeEntry( " ", );
  • ; KConfig XT, .
  • .kcfg XML, , setDefault() reset .
+1

All Articles