Unsolved Change path of saving file QSettings
-
I have object of QSettings.
QSettings settings("save.ini", QSettings::IniFormat);
but what if i wanna to change path? For example i want to
settings
saves my values in"../anothersave.ini"
. How can i do that? -
hi @Kaznachei
when you don't specify a path in the QSettings constructor, than the file will be relative to exe executable.
Therefore
QSettings settings("save.ini", QSettings::IniFormat); == QSettings settings("path/toExecutable/save.ini", QSettings::IniFormat);
Therefore you can use applicationDirPath to get the path to your exe
QSettings settings("save.ini", QSettings::IniFormat); == QSettings settings(QCoreApplication::QCoreApplication::applicationDirPath() + "/save.ini", QSettings::IniFormat);
Now, knowing that. your an save the path in a QString and manipulate it, so that it points to an other folder and than pass that one in the Settings constructor.
-
I got it. But i asked how can i change path after initialization?
-
Hi,
If by that you mean you want to change the path of an existing QSettings object, you can't.