Reply
Thread Tools
shep's Avatar
Posts: 85 | Thanked: 65 times | Joined on Jan 2010 @ Ireland
#1
Hi All,

I have a Qt app and I want the users to be able to save some config settings in a simple text file.

I have it all working (now there's a miracle), but I'm saving the file to /home/user/MyDocs/myapp.config

I'm pretty sure that's a lousey place to put it!

Is there a convention for where apps should store data files? for my next app I intend implementing a lot more file IO.

Shep
 
Posts: 1,746 | Thanked: 2,100 times | Joined on Sep 2009
#2
I seem to recall a post or two regarding this recently, however I cannot recall where they are.

When saving application settings on Linux (and therefore Maemo) you want to save them in the user's home directory, in a subdirectory or file whose name begins with a period.

Thus the path to your settings directory (or file) would be:

/home/usr/.myapp
or
/home/usr/.myapp.conf

You can see this on your device if you go to the terminal and type:

ls -la
 

The Following User Says Thank You to wmarone For This Useful Post:
VDVsx's Avatar
Posts: 1,070 | Thanked: 1,604 times | Joined on Sep 2008 @ Helsinki
#3
Originally Posted by shep View Post
Hi All,

I have a Qt app and I want the users to be able to save some config settings in a simple text file.

I have it all working (now there's a miracle), but I'm saving the file to /home/user/MyDocs/myapp.config

I'm pretty sure that's a lousey place to put it!

Is there a convention for where apps should store data files? for my next app I intend implementing a lot more file IO.

Shep
If only the app should modify that file, you should put it in '/home/usr/.myapp', in the current location the user will see the file when in mass storage mode, and some users will delete it by accident .
__________________
Valério Valério
www.valeriovalerio.org
 

The Following User Says Thank You to VDVsx For This Useful Post:
zwer's Avatar
Posts: 455 | Thanked: 782 times | Joined on Nov 2009 @ Netherlands
#4
Tho, if you plan on storing large files (videos, music, maps, whatever) you should probably put them on the mass storage partition. For my tests I use /home/user/MyDocs/.appName/ . It will show up to users in Mass Storage mode, but not when using PC-Suite Mode... Either way, that should be a place where you store non-essential large data.
__________________
Man will never be free until the last king is strangled with the entrails of the last priest.
 

The Following User Says Thank You to zwer For This Useful Post:
pbouda's Avatar
Posts: 35 | Thanked: 37 times | Joined on Nov 2009 @ Alcanena / Portugal
#5
I use QSettings in my Qt apps. It creates a config file for you in .config/CompanyName/AppName.conf. You can set the company name and application name when creating the QSettings object:

QSettings settings("CompanyName", "AppName");
settings.setValue("myConfigValue", 10);

I think this is the easiest way to save config data in your application.

Peter

Last edited by pbouda; 2010-02-06 at 20:44.
 

The Following 4 Users Say Thank You to pbouda For This Useful Post:
shep's Avatar
Posts: 85 | Thanked: 65 times | Joined on Jan 2010 @ Ireland
#6
Originally Posted by pbouda View Post
I use QSettings in my Qt apps. It creates a config file for you ...
Peter
Thanks a million for this, I have implemented this now and it works great.
 
Reply


 
Forum Jump


All times are GMT. The time now is 15:54.