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 path

QSettings file path

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k 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.
  • J Offline
    J Offline
    johnmerlino
    wrote on last edited by
    #1

    I am looking at a Qt project. I know that QCoreApplication provides an event loop. Below it sets the organization name and application name:

    @ app = new QCoreApplication(argc, argv);
    QCoreApplication::setOrganizationName("GuardDog");
    QCoreApplication::setApplicationName("MyGateway");
    int rc = app->exec();@

    Now below is what confuses me a little. When we initialize a QSettings instance, I know that the QSettings constructor is invoked, which constructs a QSettings object for accessing settings of the application, such as the organization name and application name. But then below that we make a call to this method fileName(). Now this returns a path where settings are stored. My question is how did it generate this path?

    @QSettings settings;
    settings.fileName() // home/guarddoguser/.config/GuardDog/MyGateway.conf@

    I know that GuardDog is the organization name and MyGateway is the application name. But how did it know to add a .config directory and attach a .conf to the application name? Is this something that QSettings does behind the scenes, or is there something else going on?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since you don't set anything specifically, you are using the default OS specific settings backend that does this for you. On Windows you'll be using the registry and on OS X a plist file located in ~/Library/Preferences

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

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