QSettings - where is the location of the ini file?

前端 未结 9 2067
悲哀的现实
悲哀的现实 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:12

    If you create a QSettings without giving any specific path, the ini file will be located in the application path.

    QSettings Settings("myapp.ini", QSettings::IniFormat);
    Settings.setValue("Test", "data");
    
    //...
    qDebug() << QApplication::applicationDirPath();
    

    Be careful though : the application path might change : for instance, if you are developping your app with Qt Creator, in debug mode, the application path is in the /debug subfolder.

    If you are running it in release mode, the application path is in the /release subfolder.

    And when your application is deployed, by default, the application path is in the same folder as the executable (at least for Windows).

提交回复
热议问题