Qt 5.11 can't save config value to .ini file by QSettings

911 Views Asked by At

I have a config.ini in my project.The content is

[Info]
username = "admin"

I wanna to change "/Info/username" like this:

QSettings *config = new QSettings(":/config/config.ini", QSettings::IniFromat);
QString username = "myname";
config->setValue("/Info/username", username);

Then I qDebug the value of username

qDebug() << config.value("/Info/username").toString();

It will be ok, the value of username in control is "myname",but when I check config.ini, I find it still is "username".That means the change of value isn't save to config.ini permanently.

How can I save my changes of value to config.ini permanently?

0

There are 0 best solutions below