how to remove .ini file
actually i have created an .ini file using QSettings in qt...now i have a button called reset..what i want to do is to remove the .ini file on click of reset button..but i dont understand how can i do it..i had QSetting remove() functions..but doesnt work...code i had written is..
QString strRegPathName("/SeeCycleApp-build-desktop/debug/Unknown Organization.ini");
I would use "bool QFile::remove()":
@QFile file("/SeeCycleApp-build-desktop/debug/Unknown Organization.ini");
To cite the documentation:
bq. Removes the setting key and any sub-settings of key.
Doen't sound like it takes a filename, does it?
And to read further:
bq. If key is an empty string, all keys in the current group() are removed.
So why not give
But I think he wants to remove the file and not the keys!?
If he wants to reset the stored values, then calling remove("") is equivalent to removing the file.
If removing the file is absolutely necessary, then one must be very careful to actually having a file to remove (do not remove the windows registry file...). And on a Mac it's different beast too. To actually remove the file, QFile::remove("path") is the way to go, that's right.
Where can I find the information that remove(""), removes the file? I cannot find somthing like this in the documentation!
Don't mix QSettings::remove() and QFile::remove().
QSettings::remove with argument "" simply deletes all keys from the settings file, but the file is not deleted. That bascically resets the settings.
QFile::remove() deletes a file from the hard disk.
So it was a simple misunderstanding!
This happens. Mixing to many removes sometimes causes a brain dump :)
But I was laughing by the thoughts about to remove the complete registry by using QSettings::remove("") ;-)
Actually QFile::remove is working fine...but the thing is that when i change the address of my app its not working moreever when i build the application in the device its not working..so how can i do it so that whether i change the position or build in device it will remove the .ini file..
when the location of your ini-file is changing all the time, this is not what you typically want with QSettings.
Therefore you have in Windows the possibility to use the registry, but this is sometimes less handy, because it is basically one file with the whole (registry) information of your installation.
You are using linux. In your example you have a fixed file name for your trial to remove the .ini-file. Check-out "QSettings":http://doc.qt.nokia.com/latest/qsettings.html#QSettings-4 . there you can use also a fixed name for opening the .ini-file. That is what you need anyhow. Changing locations of QSettings are not very helpful.
Why do you want to remove the file? This is completely contrary to what the persistence of QSettings is meant for.