File position using QSettings
-
Hi All,
I'm here again with my question.
Provided that I'm working on Ubuntu OS, I'm using the QSettings objects to get some information are needed from my app to work properly. Now, I want to know if I write the code:
@
QSettings mySettings("myfile.ini", QSettings::IniFormat);
@Where the QSettings look for the file which has to be open? I thought it was on the app folder but, it seems to be not like that.
-
See "QSettings":http://qt-project.org/doc/qt-4.8/QSettings.html documentation and more particularly the "this":http://qt-project.org/doc/qt-4.8/QSettings.html#locations-where-application-settings-are-stored section.
-
It goes in your ~/.config folder, under a folder named after your "organizationName":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#organizationName-prop and a subfolder named after your "applicationName":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#applicationName-prop
-
[quote author="napajejenunedk0" date="1350984657"]See "QSettings":http://qt-project.org/doc/qt-4.8/QSettings.html documentation and more particularly the "this":http://qt-project.org/doc/qt-4.8/QSettings.html#locations-where-application-settings-are-stored section.[/quote]
I've already seen and read the Qt documentation about QSettings Obj.
[quote author="rcari" date="1350984780"]It goes in your ~/.config folder, under a folder named after your "organizationName":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#organizationName-prop and a subfolder named after your "applicationName":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#applicationName-prop[/quote]
I've not set the organizzationName and the applicationName and searching the ~/.config folder on my system I don't have any folder named like this.
-
The QSetting constructor you are calling is using the file name as is, which means it looks for it in the current directory, which is more likely the directory you launched the application from, not necessarily the one where the application executable is. To get the latter you can use:
@QSettings mySettings(QApplication::applicationDirPath() + "/myfile.ini", QSettings::IniFormat);@
You would have to prefix explicitly the file path with QDesktopServices::storageLocation(QDesktopServices::DataLocation) (+ "/") instead to look for the file in ~/.config/organizationName/applicationName