2

Is there a way to get ProgramData path in QT using QStandardPaths.

Details:

  1. I want to know how to get ProgramData path by using functions of QStandardPaths class.
  2. I want cross-platform solution, that is why I want to use QStandardPaths. I believe QT provides such a solution but I could not find it.
  3. People may ask why I want that, or may suggest it is not good to use ProgramData path. First of all, I am planning to copy there user-independent config file of my app. I want all users to be able to reach that file, only for reading. I am going to locate necessary files in setup step. (We can discuss that situation though, if this is not a good way to do it)

What I have tried already:

  1. QStringList locations = QStandardPaths::locateAll(QStandardPaths::DataLocation, QString(), QStandardPaths::LocateDirectory);

  2. QStringList locations2 = QStandardPaths::standardLocations(QStandardPaths::DataLocation);

  3. I tried to run my QT as admin (to see if problem is due to some privilege issue) and nothing has changed

With the functions from point 1 and 2 I also tried to use QStandardPaths::GenericDataLocation as a standard location type. Actually, I have tried all types in this link which has "ProgramData" in its explanations

At the end, all I get are:

  1. C:/Users/myUser/AppData/{Local|Roaming}

  2. /Data

  3. empty QString.
2
  • 1
    This does not really answer your question directly, but for storing user-independent configurations I suggest using QSettings with QSettings::SystemScope. Commented Oct 13, 2015 at 8:19
  • cant we use something like this QString path1 = "C:/ProgramData/"; QDir dir1(path1); dir1.setFilter(QDir::NoDotAndDotDot|QDir::Files); not sure just asking Commented Oct 13, 2015 at 9:19

1 Answer 1

1

This looks like a bug in Qt, already reported in QTBUG-44348 and in QTBUG-40565

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.