Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QSettings file path
johnmerlino last edited by
I am looking at a Qt project. I know that QCoreApplication provides an event loop. Below it sets the organization name and application name:
@ app = new QCoreApplication(argc, argv);
int rc = app->exec();@
Now below is what confuses me a little. When we initialize a QSettings instance, I know that the QSettings constructor is invoked, which constructs a QSettings object for accessing settings of the application, such as the organization name and application name. But then below that we make a call to this method fileName(). Now this returns a path where settings are stored. My question is how did it generate this path?
settings.fileName() // home/guarddoguser/.config/GuardDog/MyGateway.conf@
I know that GuardDog is the organization name and MyGateway is the application name. But how did it know to add a .config directory and attach a .conf to the application name? Is this something that QSettings does behind the scenes, or is there something else going on?
Since you don't set anything specifically, you are using the default OS specific settings backend that does this for you. On Windows you'll be using the registry and on OS X a plist file located in ~/Library/Preferences