Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QSettings file MIA



  • In using this code,

    QSettings settings("MyCompany", "MyApp");
        settings.beginGroup("AltGridColors");
        settings.setValue("cust-alt-grid-color", color);
        settings.endGroup();
    

    I can't find a file in my project folder where this is being stored.

    However, when I use this code,

    QSettings* settings = new QSettings(QDir::currentPath() + "/MyApp.ini", QSettings::IniFormat);
    settings.beginGroup("General");
    settings->setValue("test", "this");
    settings.endGroup();
    

    I get an .ini file, a file I can see in the project folder.

    Where is the code stored for the first use? Also, what does settings->sync(); do?


  • Lifetime Qt Champion

    @Driftwood Did you read https://doc.qt.io/qt-5/qsettings.html ?
    On Windows default location for settings is Windows Registry.



  • On Windows, the ini-format settings file is usually in 'C:/Users/{User Name}/AppData/Roaming/{Company Name}/{Appname}.ini

    Note, AppData is typically a hidden folder so you have to select 'show hidden items' in the File Explorer's view settings.



  • @jsulm said in QSettings file MIA:

    @Driftwood Did you read https://doc.qt.io/qt-5/qsettings.html ?
    On Windows default location for settings is Windows Registry.

    Just read the doc and see that QSettings defaults to QSettings::NativeFormat, which uses the Windows registry, demonstrated in my first code block. And then settings->sync() "imports changes made by other processes (in addition to writing the changes from this QSettings)."

    Note to self: Read first :D

    @jsulm - Thank you.


Log in to reply