Nominate our 2022 Qt Champions!

How can we change the file path of ini file ?

  • Suppose initially i have given path
    @setting = new QSettings("../mainwindow/../../Aqua/SKIN.ini",
    later on i want to change path of file location to

    So how can i do that? I have tried
    @set path() @
    but i didn't find any change in path in my .ini file.

  • Are you sure that anything like that is actually possible?

    The path to the .ini file is given to the constructor of the QSettings object and the constructor is executed only once in the life of this object (at the object construction time).

    So, as long as I can see, there is no way to redefine this variable later (Or, at least, I cannot see any method to perform such a action in the QSetting's documentation).

    Most likely, you should destroy the existing QSettings object and create a new one, with a new path to the .ini file.

  • You will need to move the file using other code. The file will not magically relocate.

Log in to reply