[Interest] QSettings: no settings file

Till Oliver Knoll till.oliver.knoll at gmail.com
Wed Feb 19 19:10:00 CET 2014


Am 19.02.2014 um 16:28 schrieb Sensei <senseiwa at gmail.com>:

> ....
> I create the QSettings as follows, given the suggestion about submitting 
> the app to the Mac AppStore in [1]. The getPreferences() function 
> returns just QString("%1/Library/Preferences").arg(getenv("HOME")).
> 
> 
> instance_->settings_ = new QSettings(getPreferences() + 
> "/0com.example.app", QSettings::NativeFormat);

You should set your application name (e.g. "superapp"), company and -important- domain (e.g. "supercompany.com" with the corresponding methods in QApplication (or QCoreApplication - check docs).

The (reversed) domain and app name should match with the "Bundle ID" (e.g. "com.supercompany.superapp").

Once you have done so (in main(), before instantiating your QApplication) you should be able to simply say

  QSettings settings; // default on Mac is PLIST, name and location derived from app name and domain set above

and your 'settings' instance will automagically read/write from/to the proper file.

Also refer to Qt blog a couple of months ago "how to submit to Mac App Store" (consult google).

And just to state the obvious: if you already have code-signed your app at this point of testing you won't find the preference file where you are looking for it: it will be in the "app container" instead (~/Library/Containers/[Bundle ID]/... or so).

But as Thiago said, you might be leaking your settings instance and values are hence never stored to disk...

Cheers,
  Oliver


More information about the Interest mailing list