[Qt-interest] QSettings default scope on Mac

KC Jones kc at asperasoft.com
Wed Jan 13 00:52:18 CET 2010


While writing a unit test for some QSettings related code, I'm
noticing odd results on Mac that I need to understand.  The scope of a
QSettings store appears to include lots of system related settings I
do not expect.  This is a problem for my unit test since I want to
clear out test settings, and the inclusion of external settings is a
bother/risk.

My class is using a totally default constructor for QSettings, that is
it has a QSettings member that is not specifically initialized:

class MyClass
{
    //...
    QSettings _settings;
}

I wrote some debug code to examine how it is initialized, and found
that it does appear to use QCoreApplication::setOrganizationDomain()
and QCoreApplication::applicationName() to open the file
/Users/{username}/Library/Preferences/{orgdomain}{appname}.plist

So far so good.

But when I go to look at the contents of that file, I get more than I
expected.  The following code generates a list that includes a whole
bunch of what looks like Mac system preference keys:

{
    //...
    QSettings s;
    QStringList all;
    all = s.allKeys();
    qDebug() << "Initial keys:\n..." << all.join(",\n...");
}

Which produces lots of output of the form:
Initial keys:
... "AppleAntiAliasingThreshold,
...AppleCollationOrder,
...AppleEnableMenuBarTransparency,
...AppleLanguages,
...AppleLocale,
...AppleShowAllExtensions,
...ColorSyncDevices,
...Country,
...com/apple/AppleModemSettingTool/LastCountryCode,
...com/apple/TimeZonePref/Last_Selected_City,
...com/apple/mouse/swapLeftRightButton,
...com/apple/mouse/tapBehavior,
...com/apple/springing/delay,
...com/apple/springing/enabled,
...com/apple/trackpad/enableSecondaryClick,
...com/apple/trackpad/scrollBehavior,
...com/apple/userspref/DisableAutoLogin,
...com/omnigroup/OmniGraffle:5:1,
...com/omnigroup/OmniGrafflePro:5:1,
...com/picodev/Versions/ezsAuthorizedLibs,

Where do these keys come from and how can I tell them from my own?

PS: the problem does not appear to exist on Windows.  Have not tried
other platforms.



More information about the Qt-interest-old mailing list