Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
What may be the error in following syntax?
@QSettings* s = new QSettings(QDir::currentPath() + "/my_file.ini" , QSettings::IniFormat);@
Here if .ini file does not exist it should create new file but it is not creating.
veeeee_d last edited by
Check the path you're trying to create the file on.
i have checked the path is correct
fluca1978 last edited by
Uhm..could it be a problem with the path separator? Have you tried to debug/print the real file name that is created?
If that is correct, I will try to create an empty file in such directory to see if there is also a permission problem.
one thing i notice that if we will setvalue for the first time then only file will be created if it doesn't exist.
koahnig last edited by
In the documentation you find:
@Constructs a QSettings object for accessing the settings stored in the file called fileName, with parent parent. If the file doesn't already exist, it is created.
However, that is apparently not completely correct. I have just created an object with a fixed path and iniformat. I have not done anythingelse with that object. It was not created.
When I set a value as you have as you have indicated, the ini-file will be created.
So QSettings will only create a file, when information is available to be stored.
rcari last edited by
Do you have write access to the QDir::currentPath() directory ?
Rahul Das last edited by
Code is ok. As koahnig told, it will create the ini file, only when you set a value.
If no values are there, you wouldn't need an empty file right ?