Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Standard path for common application data
Does Qt provide a way to find the location for common application data?
QStandardPaths enum includes AppConfigLocation. However, the return value on my Windows 10 machine is C:/Users/<UserName>/AppData/Local/<Organization>/Application/. This is a user-specific location. How do I write my application so it can share data files between users? BTW, I use Qt 5.6
Yes it does: QStandardPaths
Sorry, misread your question. What kind of file do you intend to share between users ?
Might be the
C:\Users\Publicfolder that you want to use ?
It is a data file we make at "the factory". It controls the application behavior. Essentially "the factory" wants to configure an application for all users. When a new version is shipped and installed such configuration file may change. On Windows 7-10 such files are typically prescribed to be placed in C:\ProgramData.
C;\Users\Public is not really appealing because we would rather keep configuration files not readily exposed to end users. Nonetheless, I will look into this option.
Should that file be changed by other means ?
mchinand last edited by
Can you use QSettings for this data? If so, check out the scope settings of QSettings. The Platform specific notes section describes where the data will be stored depending on what format you've chosen.
@mchinand When the format is set to IniFormat and scope is set to SystemScope QSettings behaviour is exactly what I was looking for. I will be able to use it. Thanks.
On the other hand, this inquiry discovered two Qt blemishes
- QStandardPaths does not provide access to the IniFormat/SystemScope directory
- Platform specific notes of QSettings documentation is outdated. It mentions %COMMON_APPDATA% which no longer exists on Windows 10 (maybe even earlier).
Platform specific notes of QSettings documentation is outdated. It mentions %COMMON_APPDATA% which no longer exists on Windows 10 (maybe even earlier).
The variable is valid for Windows 7 (probably 8 as well), so there's no fault here.
@kshegunov I just tried pointing Windows Explorer to %COMMON_APPDATA% on Windows 7 computer and received an error dialog!(
Looks to me like something is wrong with your statement.
It is possible, I haven't double-checked as I currently don't have a windows at hand.