Wouldn't it return the same path for all users using the same installation? (e.g. /usr/bin/ on Linux)
I expected to generate something more like /home/user/.myprogram/ in order to have something unique. Eventually I came with this solution to create a per-user profile directory and register it to the settings:
void checkUserProfileDirectory()
{
if (!settings.contains("userProfile")) {
profileDirName.resize(profileDirName.lastIndexOf('.'));
settings.setValue("userProfile", profileDirName);
}
else profileDirName = settings.value("userProfile").toString();
QDir profileDir
(profileDirName
);
if (!profileDir.exists()) profileDir.mkpath(".");
}
void checkUserProfileDirectory()
{
QSettings settings;
QString profileDirName;
if (!settings.contains("userProfile")) {
profileDirName = QDir(QSettings(QSettings::IniFormat, QSettings::UserScope,
QCoreApplication::organizationName(), QCoreApplication::applicationName()).fileName()).path();
profileDirName.resize(profileDirName.lastIndexOf('.'));
settings.setValue("userProfile", profileDirName);
}
else profileDirName = settings.value("userProfile").toString();
QDir profileDir(profileDirName);
if (!profileDir.exists()) profileDir.mkpath(".");
}
To copy to clipboard, switch view to plain text mode
I'd gladly take any better solution though.
Bookmarks