Settings file inconsistency between linux and mac
-
running same program uses settings file in different locations between ubuntu and osx:
ubuntu:
Settings file: /home/guarddog/.config/GuardDog/Gateway.confosx:
Settings file: /Users/GuardDog/Library/Preferences/com.guarddog.Gateway.plistI understand the use of the domain for osx, as the qt documentation states the following: "When the Internet domain is set, it is used on Mac OS X instead of the organization name". That's fine, but why on mac is the settings file set in Library/Preferences folder and why does it have an extension plist?
-
Hi,
Because by default QSettings uses the platform implementation thus in OS X it's a plist file located there
-
I suggest you to have a look at Platform-Specific Notes provided with the documentation of "QSettings":http://qt-project.org/doc/qt-5/qsettings.html
If you can set a custom file format at constructor of QSettings or change the default format using the static method "setDefaultFormat(Format format)":http://qt-project.org/doc/qt-5/qsettings.html#setDefaultFormat -
Why would you want to store settings in the exactly same way on each platform, anyway? I think the idea is that QSettings provides an interface that allows your application store/load its settings in a platform-independent way. Internally, however, QSettings stores the settings in the way that is the usual and recommended one, for each platform. So on Windows it uses the Registry, on Mac OS X it uses a .plist file, and so on. But since these details are hidden inside QSettings, your application doesn't need to worry at all ;-)
As others have said, you can force a specific method, if you really have to. But I think you shouldn't do that, unless you have a good reason...
[quote]QSettings::NativeFormat
Store the settings using the most appropriate storage format for the platform.[/quote]
-
bq. Why would you want to store settings in the exactly same way on each platform, anyway?
If you wanted to provide a mechanism in your program to backup settings and user data and restore it on any supported platform. You could go to the effort of providing a separate serialisation/deserialisation for the settings, but why bother if a simple INI file is nicely portable.