QSettings. setPath with systemScope ignores userScope
I want to have my applications and system .ini-files on a network disk. These program lines are in the main.cpp-file:
QCoreApplication::setOrganizationName("MyOrganization"); QCoreApplication::setApplicationName("MyApp"); QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setPath(QSettings::IniFormat,QSettings::SystemScope,QCoreApplication::applicationDirPath());
The directory C:/Documents and Settings/myUser/Programdata/MyOrganization (%APPDATA%) contains a MyApp.ini-file.
But the application reads the settings information from the directory ...applicationDirPath/MyOrganization on the network disk, which is specified for SystemScope in setPath. The function settingsObject.scope() in MyApp reports QSettings::UserScope.
I want to use the system MyApp.ini-file as a fallback, and userScope writing to be done to the userScope %APPDATA%/MyApp.ini-file on the local disk. A common user should not be allowed to do writing to the system .ini-file. The way I understand the QSettings documentation (http://doc.trolltech.com/4.7/qsettings.html#setPath) my program should work that way.
Have I missed something ??
settingsObject.scope() returns the scope where settings will be written, that's not necessarily the scope where settings are read.
Perhaps I did not make myself quite clear. I use Windows XP and QtCreator 2.0.1. When I do not use setPath, QSettings reads from and writes to the %%APPDATA%% .ini-file. When I have called setPath with SystemScope, QSettings (in UserScope mode) afterwards ignores %%APPDATA%% and reads and writes from applicationDirPath. That is not the way I understand the documentation. Are there another way to ensure that the .ini-file at applicationDirPath is only read from as fallback (when the %%APPDATA%% .ini-file does not contain the relevant key), and that the %%APPDATA%% .ini-file (and not the applicationDirPath .ini-file) is written to in UserScope ?
It could be that the system ini file is only read when there is no user file at all. I did not try this before.