QSettings - where is the location of the ini file?

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

    QSettings save location changes to the QSettings.Scope enum. QSettings save to the Local scope by default. On Linux, I found my local settings in:

    ~/.config/CompanyName/ApplicationName.conf

    0 讨论(0)
  • 2021-02-03 22:20

    Check out the QStandardPaths class, it links to multiple standard paths including configuration on all supported platforms. https://doc.qt.io/qt-5/qstandardpaths.html

    QT >= 5.5:

    QString path = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
    

    QT < 5.5:

    QString path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
    

    There are paths for config files in shared config directories, application data directories, and more.

    0 讨论(0)
  • 2021-02-03 22:20

    In linux you can use this snippet or insert this lines into your main code for find location of your file with python.

    from PyQt5.QtCore import QSettings
    
    settings = QSettings("Organization Name", "App name")
    print(QSettings.fileName(settings))
    

    It should return an output like this.

    /$HOME/.config/Organization Name/App name.conf

    Source

    0 讨论(0)
提交回复
热议问题