Program data locations
I am developing a desktop application and need to find somewhere to store persistent data. This data needs to be shared with all users of the pc upon which the application is stored.
I have looked at QStandardPaths and the DataLocation, but when I use
QStringList sl = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
I get 2 paths one to the users AppData/Local folder with the organisation and application names appended and one to C:/ProgramData (again with the names appended)
Now I know that I need to user the second one,
but am I guaranteed that the this will always be in the second position
will it work cross platform?
is there a better way
Thanks for you time
use "QStandardPaths::writableLocation()":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html#writableLocation instead.
I did that and passed GenericDataLocation
This returned a path for the current user , whereas I need a location accessible by ALL users
hmmm...seems that all "QStandardPaths::StandardLocation enum":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html#StandardLocation-enum values are user specific then...
What does QStandardPaths::RuntimeLocation return?
Putting data into a path that is writable for all users is a security risk as every user of the machine can go ahead and corrupt your data for you. That is why there is no such location available.
I recommend running a service to manage the data and the access to it (which can then store into the user location) and having client UI applications interact with that service.
What is meant by a 'service' ?
"guaranteed to be in second position" - not necessarily, there could be more, but the order is always "most local" to "most global". So using .last() is the best way to get the most global directory.