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. How to always get "C:\ProgramData" type location from QStandardPaths ...
Forum Updated to NodeBB v4.3 + New Features

How to always get "C:\ProgramData" type location from QStandardPaths ...

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.4k 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.
  • T Offline
    T Offline
    tmason101
    wrote on 19 Sept 2014, 16:29 last edited by
    #1

    Hello,

    I am in need of getting the standard configuration directory that my application can write to system-wide.

    I have the following code snippet that sort of works for this purpose, with one major problem:

    @
    QStandardPaths* PathsToStandardLocations;

    QStringList FolderPaths = PathsToStandardLocations->standardLocations(QStandardPaths::ConfigLocation);

    GLint NumberOfPaths = FolderPaths.count();

    std::string CompletePath = FolderPaths[1].toStdString();
    @

    So, I get the configuration as requested, EXCEPT I get four (4) locations back, with some of them being user directory locations!

    Is there something I am missing with QStandardPaths? How can I get JUST the system-wide location that my application can write to without generally worrying about permission stuff for all users?

    Thank you.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chrisaverage
      wrote on 19 Sept 2014, 17:53 last edited by
      #2

      The documentation is clear on the QStandardPaths::ConfigLocation:

      bq. Returns a directory location where user-specific configuration files should be written. This may be either a generic value or application-specific, and the returned path is never empty.

      Also, very important note:

      bq. The first path is the writable path (unless noted). Other, additional paths, if any, represent non-writable locations

      The thing is in modern OSes there is no such thing as "without worrying about permission stuff for all users". A user is always logged in with certain permissions and your app always runs as a specific user and you do have to worry about that. Most of the "standard paths" are thus user-specific.
      The ProgramData (which can be located anywhere really) folder is not always accessible to all users. It's a location where a user with administrative privileges can setup a folder with permissions it chooses. This is usually done by the installer.
      If you want a single, writable location for the running app use writableLocation() instead of standardLocations().

      1 Reply Last reply
      0

      1/2

      19 Sept 2014, 16:29

      • Login

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