[SOLVED] What is the best path to save some settings/images in Windows?
-
So in ubuntu it is home/.appname.. with the dot it makes it invisible for the user unless he press ctrl+h
well in windows it is kinda ugly to have it at /username/.appname.. it is visible everytime and the only application in my computer doing this is gimp.. there must be a certain path in windows for that reason..
-
Take a look at [[doc:QDesktopServices]]. It has a method to discover the path names to use for specific things. In your case, I would use QDesktopServices::DataLocation
-
I just have some research on this.
in Windows, i mean, win7, there is a path named "%system%/users/%USERNAME%/AppData/". u can use this path to save your settings.
there are 3 folder in this path, "local", "localLow", and "roaming".
in roaming, it stores all settings for your apps, the files in this folder will not be removed.
in others, it stores temp files for your apps, the files will be removed by some clean app. -
BTW, u can use QDir::homePath() to get current user path.
-
[quote author="Andre" date="1348213480"]Take a look at [[doc:QDesktopServices]]. It has a method to discover the path names to use for specific things. In your case, I would use QDesktopServices::DataLocation[/quote]
Andre
@QString(QDesktopServices::DataLocation)@
or
@QString(QDesktopServices::displayName(QDesktopServices::DataLocation))@will return me an empty string. why is that?
-
[quote author="Landy" date="1348215176"]I just have some research on this.
in Windows, i mean, win7, there is a path named "%system%/users/%USERNAME%/AppData/". u can use this path to save your settings.
there are 3 folder in this path, "local", "localLow", and "roaming".
in roaming, it stores all settings for your apps, the files in this folder will not be removed.
in others, it stores temp files for your apps, the files will be removed by some clean app.
[/quote]i want to make the application cross platform so i can't do that...
-
[quote author="Leon" date="1348215468"]
[quote author="Andre" date="1348213480"]Take a look at [[doc:QDesktopServices]]. It has a method to discover the path names to use for specific things. In your case, I would use QDesktopServices::DataLocation[/quote]Andre
@QString(QDesktopServices::DataLocation)@
or
@QString(QDesktopServices::displayName(QDesktopServices::DataLocation))@will return me an empty string. why is that?
[/quote]
Because that is not how you use these constants. You should use them as the argument for the storageLocation() method of that class.
-
Xmm ok it works but 2 questions..
Windows uses backslashes but Ubuntu us slash.. will this be a problem if u use slashes in windows?because for example telling qdir to create this folder
@C:\Users\CityBong\AppData\Local/.appname/@
will work perfectly.. but this won't work always? that's why i am asking..And 2nd question, as i said in Ubuntu it is home/.appname.. with the dot it makes it invisible for the user unless he press ctrl+h... ok? But in Windows creating a folder at C:\Users\CityBong\AppData\Local
with a dot isn't the correct i quess.. all the apps there aren't starting with a dot.. Any ideas? -
Within your application, Qt recommends you use forward slashes for paths on all operating systems. Translate from 'native' on user input, and translate back to native for display or external tools that expect a certain format. Internally in Qt, you can use forward slashes everywhere.
On your hidden question: on windows, the AppData directory itself is already hidden.
-
Ok, i appreciate your answers Andre! Thanks.