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. Program data locations

Program data locations

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 5.3k Views
  • 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.
  • G Offline
    G Offline
    GrahamL
    wrote on last edited by
    #1

    Hi
    I am developing a desktop application and need to find somewhere to store persistent data. This data needs to be shared with all users of the pc upon which the application is stored.
    I have looked at QStandardPaths and the DataLocation, but when I use
    @
    QStringList sl = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
    @
    I get 2 paths one to the users AppData/Local folder with the organisation and application names appended and one to C:/ProgramData (again with the names appended)

    Now I know that I need to user the second one,

    but am I guaranteed that the this will always be in the second position

    will it work cross platform?

    is there a better way

    Thanks for you time

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      use "QStandardPaths::writableLocation()":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html#writableLocation instead.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GrahamL
        wrote on last edited by
        #3

        Hi
        I did that and passed GenericDataLocation
        This returned a path for the current user , whereas I need a location accessible by ALL users

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          hmmm...seems that all "QStandardPaths::StandardLocation enum":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html#StandardLocation-enum values are user specific then...
          What does QStandardPaths::RuntimeLocation return?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • G Offline
            G Offline
            GrahamL
            wrote on last edited by
            #5

            returns C:/Users/Graham.Labdon

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #6

              Putting data into a path that is writable for all users is a security risk as every user of the machine can go ahead and corrupt your data for you. That is why there is no such location available.

              I recommend running a service to manage the data and the access to it (which can then store into the user location) and having client UI applications interact with that service.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                GrahamL
                wrote on last edited by
                #7

                Thanks Tobias

                What is meant by a 'service' ?

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dfaure
                  wrote on last edited by
                  #8

                  "guaranteed to be in second position" - not necessarily, there could be more, but the order is always "most local" to "most global". So using .last() is the best way to get the most global directory.

                  David Faure (david.faure@kdab.com)
                  KDE/Qt Senior Software Engineer
                  KDAB - Qt Experts - Platform-independent software solutions

                  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