Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QSettings - where is the location of the ini file?

Tags:

qt

ini

qsettings

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 may be I miss the code which write it to the file? When does the QSettings write its values?

like image 941
dubila Avatar asked Oct 27 '10 09:10

dubila


People also ask

Where are QSettings stored Windows?

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.

Where are QT settings stored Linux?

$HOME/. config/MySoft. conf (Qt for Embedded Linux: $HOME/Settings/MySoft. conf )

What is INI configuration file?

An . INI file is a type of file that contains configuration information in a simple, predefined format. It is used by Windows OSs and Windows-based applications to store information about the user's preferences and operating environment.


2 Answers

To print out the exact location of your settings file use method fileName method of QSettings class.

QSettings settings("folderName", "fileName"); qDebug() << settings.fileName(); 

Console output looks then like:

/home/user/.config/folderName/fileName.conf 
like image 76
lucaboni Avatar answered Sep 29 '22 07:09

lucaboni


I think you'll find everything you're looking for here : http://doc.qt.io/archives/qt-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); 
like image 21
Andy M Avatar answered Sep 29 '22 06:09

Andy M