Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt QSettings try to create ini file but none created why?

Tags:

c++

qt

qsettings

Im trying to create ini file that will hold me the configuration data, I have singletone class that setting the QSettings object like this :

... #DEFINE CONFIG_FILE_NAME "myconfig.ini"

m_pSettings = new QSettings(QDir::currentPath()+"/"+CONFIG_FILE_NAME,QSettings::IniFormat);

this is accourding the document, but when i look in my application dir, there is none myconfig.ini file created, what im doing wrong ?

like image 851
user63898 Avatar asked Apr 03 '11 11:04

user63898


1 Answers

I believe in order to force QSettings file to appear you would need to set at least one value in it and then call sync() method. See if an example below would work for you:

QSettings* settings = new QSettings(QDir::currentPath() + "/my_config_file.ini", QSettings::IniFormat);
settings->setValue("test", "value");
settings->sync();

hope this helps, regards

like image 194
serge_gubenko Avatar answered Oct 15 '22 09:10

serge_gubenko