QSettings - where is the location of the ini file?

前端 未结 9 2156
悲哀的现实
悲哀的现实 2021-02-03 21:45

I\'m using QSettings to store some data as ini file in Windows. I want to see the ini file, but I don\'t know what is the location of the ini file.

This is

9条回答
  •  無奈伤痛
    2021-02-03 22:14

    On Windows without providing an ini filename, you'll find the data in the registry. Using this code snippet:

        int red = color.red();
        int green = color.green();
        int blue = color.blue();
        QSettings settings("Joe", "SettingsDemo");
        qDebug() << settings.fileName();
        settings.beginGroup("ButtonColor");
        settings.setValue("button1r", red);
        settings.setValue("button1g", green);
        settings.setValue("button1b", blue);
        settings.endGroup();
    

    After running this code, you'll see the output:

    "\\HKEY_CURRENT_USER\\Software\\Joe\\SettingsDemo"

    Now, opening the regedit tool and following the path list you got: 1

提交回复
热议问题