PDA

View Full Version : Using QSettings fallback mechanism with custom filepaths



graffy
4th May 2014, 14:35
Hello,

I have an application into which I'm trying to implement QSettings to take advantage of two particular features: file loading / saving and the fallback mechanism. The existing config files follow INI format, and use the user / system scope hierarchy, but the files use .cfg (not .conf) for their extension. ATM, the only way I can see to override the default .conf extension QSettings uses is to set the path directly when the object is constructed. But, of course, that bypasses the fallback mechanism, which I want to use.

Is there a way to specify a custom file path / file extension, but still use the built-in fallback mechanism?

anda_skoa
4th May 2014, 15:37
QSettings uses .conf when the format is NativeFormat or .ini when the Format is IniFormat.

As far as I can tell the only way to use a different extension is to use a different, custom, format.

Cheers,
_

graffy
5th May 2014, 12:46
That's what I was afraid of... Of course, that negates the purpose of implementing QSettings. :) Ah well.

Thanks!

anda_skoa
5th May 2014, 13:52
If you are in need for more advanced config handling you could have a look at the KConfig addon module: http://www.inqlude.org/libraries/kconfig.html

I can do multiple levels of fallbacks, merge values from different levels, mark entries as immutable by more local files, has a code generator for getting rid of using string based access in application code, etc.

Cheers,
_