tags:

views:

59

answers:

2

hi,

I'm using Qsettings to store some data as ini file in windows. I want to see the ini file - but I don't know what is the location of the ini file.

this is my code:

QSettings *set = new QSettings(QSettings::IniFormat, QSettings::UserScope,
                       "bbb", "aaa");
set->setValue("size", size());
set->setValue("pos", pos());

where do I have to look ? or maybe I miss the code which write it to the file? when does the Qsettings write its values?

thanks!

+3  A: 

Hey,

I think you'll find everything you're looking for here : http://doc.qt.nokia.com/4.7/qsettings.html

It's plateform specific, see under :

Platform-Specific Notes Locations Where Application Settings Are Stored

You can store Settings in files as well :

QSettings settings("/home/petra/misc/myapp.ini",
                QSettings::IniFormat);

Hope it helps !

Andy M
A: 

If you create a QSettings without giving any specific path, the ini file will be located in the application path.

QSettings Settings("myapp.ini", QSettings::IniFormat);
Settings.setValue("Test", "data");

//...
qDebug() << QApplication::applicationDirPath();

Be careful though : the application path might change : for instance, if you are developping your app with Qt Creator, in debug mode, the application path is in the /debug subfolder.

If you are running it in release mode, the application path is in the /release subfolder.

And when your application is deployed, by default, the application path is in the same folder as the executable (at least for Windows).

Jérôme