Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSettings file MIA
Forum Updated to NodeBB v4.3 + New Features

QSettings file MIA

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 405 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DriftwoodD Offline
    DriftwoodD Offline
    Driftwood
    wrote on last edited by Driftwood
    #1

    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?

    jsulmJ 1 Reply Last reply
    0
    • DriftwoodD Driftwood

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      DriftwoodD 1 Reply Last reply
      8
      • M Offline
        M Offline
        mchinand
        wrote on last edited by mchinand
        #3

        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.

        1 Reply Last reply
        0
        • jsulmJ jsulm

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

          DriftwoodD Offline
          DriftwoodD Offline
          Driftwood
          wrote on last edited by
          #4

          @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.

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved