QSettings doesn't create the INI file
-
I use the QSettings class to read an INI file and I'd like to let it create the file with default values if it doesn't exists (as it should do), but, it seems to doesn't work.
This is the code I use:
@
_m_pInstance = new QSettings(QDir::currentPath() + SETTINGS_FILE_NAME, QSettings::IniFormat, NULL);m_pInstance->beginGroup(POWER_SUPPLIERS_GROUP);
m_strMainFrm1IpAddr = m_pInstance->value(MAINFRAME1_IP_ADDR_KEY, DEF_MAINFRM1_IP_ADDR).toString();
m_pInstance->sync();_
@
If the file doesn't exist, my variable is updated with the default value but the INI file is non created.What's wrong ?
Are there other calls to do ? Is it due to the dynamical allocation of the QSettings Class ?Edit: Please surround code sections with @ tags for readability; Andre
-
-
Hi,
I think sync() will write to file only if you used QSettings::setValue(). Reading values does not change file, so sync() does not need to write it.