I am upgrading my old application to store app settings in user-specified directory.
Previously I stored it in "default" location, whatever this location is and I did not care.
Now I do care and quickly changed the code to store settings in user-specified directly. Did not work.

I could not figure out what is wrong with the code. I wrote a test to illustrate the problem I am having.
Please see the debug output - it appends organization name and domain to the specified path. WTF?
It is so counter-intuitive.

I can't change organization name etc, the app should support "old" and "new" ways. So, my questions are:
1. Perhaps I am doing something wrong. What it might be?
2. Is there a way to store ini file in specific directly in the case shown in the test below?

Thanks in advance!

Qt Code:
  1. #include <QCoreApplication>
  2. #include <QSettings>
  3. #include <QDebug>
  5. int main(int argc, char *argv[])
  6. {
  7. QCoreApplication a(argc, argv);
  9. QCoreApplication::setOrganizationName("testOrganization");
  10. QCoreApplication::setOrganizationDomain("testOrganization.org");
  11. QCoreApplication::setApplicationName("testAppName");
  12. QCoreApplication::setApplicationVersion("");
  13. QSettings::setDefaultFormat (QSettings::IniFormat);
  15. //from the documentation: This function doesn't affect existing QSettings objects.
  16. QSettings::setPath(QSettings::Format::IniFormat,QSettings::Scope::UserScope, "c:/test/testApp.ini");
  18. QSettings settings;
  19. //Returns the path where settings written using this QSettings object are stored.
  20. qDebug() << settings.fileName();
  22. // debug output: "C:/test/testApp.ini/testOrganization/testAppName.ini"
  25. return a.exec();
  26. }
To copy to clipboard, switch view to plain text mode