[SOLVED] using the prefix in a resource file
-
wrote on 8 Mar 2011, 09:17 last edited by
If you want to load an image from a certain location, use QDir::homePath(), QUrl or whatever is required (QFileDialog, QDesktopServices). If you need an image in your resource file, use the resource editor to add it and let Qt handle it. You don't need access to the home dir then.
-
wrote on 8 Mar 2011, 09:35 last edited by
im putting configuration files in the home directory.
the QFile cant read the file unless i put the file in the current folder.unix: /home/username/.myapp/files.ext
windows: c:\Documents and Settings\username\Application Data\myapp\files.ext -
wrote on 8 Mar 2011, 09:43 last edited by
On both platforms?
Why not use QSettings? -
wrote on 8 Mar 2011, 09:43 last edited by
In that case, you should look into the QDesktopServices class. It will supply you with a cross platform way to query for locations on disk like this. In your case, you are probably looking for QDesktopServices::DataLocation.
Note that inside your Qt program, you should use forward slashes for all file paths, even on Windows. Only for paths you display to the user, you can use QDir::toNativeSeparators to get the native format.
-
wrote on 8 Mar 2011, 11:28 last edited by
Franzk: i cant use QSettings cause i need to save the configurations to a file so i could load it again using the QFile then use QSettings.
Andre: i think ill try QDesktopServices::DataLocation. it seems that this directory is where my configurations files to be stored.
-
wrote on 8 Mar 2011, 11:57 last edited by
[quote author="xeroblast" date="1299583686"]Franzk: i cant use QSettings cause i need to save the configurations to a file so i could load it again using the QFile then use QSettings.[/quote]
QSettings can do ini files. You just have to explicitly tell it to do that on windows. On linux the settings are stored in ~/.config/.
-
wrote on 9 Mar 2011, 03:52 last edited by
[quote author="Franzk" date="1299585456"]QSettings can do ini files. You just have to explicitly tell it to do that on windows. On linux the settings are stored in ~/.config/.[/quote]
ok. i think this is what i want. i just didnt know where the ini files located. i thought QSettings didnt saved it.
so in windows, where is the ini files located?
-
wrote on 9 Mar 2011, 06:28 last edited by
It saves them where you tell it to save them. By default it will go for registry, but there's the option of setting the format and file: http://doc.trolltech.com/latest/qsettings.html#QSettings-4
-
wrote on 9 Mar 2011, 11:23 last edited by
thanks for the info...
-
wrote on 13 Sept 2011, 15:22 last edited by
Resolved mine also. thanks again.
Can there be a small an example put in the list also. Would help lot as most of us spend loads of time searching it.