qtsettingspreferencesqsettings

Where to find QSettings on macOS


So I am using QSettings to store my preferences, and according to https://doc.qt.io/qt-5/qsettings.html#platform-specific-notes there is several locations where this is actually stored.

I am on macOS 10.14, yet I find the settings in $HOME/Library/Preferences/org.mycomp.myapp.plist (the above link states this should be for macOS 10.2/10.3).

Now I can see by opening that this file contains my most recent settings changes, however, after deleting, my app still loads the settings. So there must be a second location where it is stored? But I can't seem to find it.

  1. $HOME/Library/Preferences/com.MySoft.Star Runner.plist - non existing
  2. $HOME/Library/Preferences/com.MySoft.plist - existed, deleted
  3. /Library/Preferences/com.MySoft.Star Runner.plist - non existing
  4. /Library/Preferences/com.MySoft.plist - non existing

And for the unix variants:

  1. $HOME/.config/MySoft/Star Runner.conf - non existing
  2. $HOME/.config/MySoft.conf - non existing
  3. for each directory in $XDG_CONFIG_DIRS: /MySoft/Star Runner.conf - non existing
  4. for each directory in $XDG_CONFIG_DIRS: /MySoft.conf - non existing

So where is the settings still saved?!

In my main.cpp I have:

    QCoreApplication::setOrganizationName("Firstname Lastname");
    QCoreApplication::setOrganizationDomain("mycomp.org");
    QCoreApplication::setApplicationName("MyApp");

And I am using QSettings with the default constructor. I am using Qt 5.13.2.


Solution

  • Since macOS Mavericks (10.9) preferences are cached to improve performance, so they say. When you delete the .plist file, they are still in memory each time you execute your program. You need to clear the preferences cache with this command:

    killall -u $USER cfprefsd
    

    Or you can reboot your computer...

    If you (and your users) are tired of this, you may consider to use INI files with QSettings instead of the native OS format:

    QSettings("MyApp.ini", QSettings::IniFormat)