Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QStandardPaths::ApplicationsLocation strange path

    General and Desktop
    3
    6
    144
    Loading More Posts
    • 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.
    • posktomten
      posktomten last edited by

      Hello!
      I've discovered something I do not understand.
      I have made a non GUI application. In my * .pro file

      QT -= gui
      TARGET = veryStrange
      

      The printout from the following code snippets

      QStringList allAppDataLocations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
      
      foreach(QString path, allAppDataLocations) {
             qInfo()  << path;
      }
      

      is

      "/home/ingemar/.local/share/veryStrange"
      "/usr/share/ubuntu/veryStrange"
      "/usr/local/share/veryStrange"
      "/usr/share/veryStrange"
      "/var/lib/snapd/desktop/veryStrange"
      

      Why "veryStrange"

      At the end of the paths? (The value of "TARGET" in my * .pro file) ?
      It is not a standard.

      posktomten

      mrjj 1 Reply Last reply Reply Quote 0
      • B
        Bonnie @posktomten last edited by

        @posktomten
        I think what you need is not AppDataLocation but ApplicationsLocation

        1 Reply Last reply Reply Quote 3
        • mrjj
          mrjj Lifetime Qt Champion @posktomten last edited by

          @posktomten
          Hi
          Also does that on Windows so seems its intended,
          The docs says
          Returns a directory location where persistent application data can be stored. This is an application-specific directory.

          So that is maybe why TARGET is used.

          posktomten 1 Reply Last reply Reply Quote 3
          • B
            Bonnie last edited by

            It is really intended. It is already written in the doc very specifically:

            Path type: AppDataLocation
            Linux: "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>"

            1 Reply Last reply Reply Quote 4
            • posktomten
              posktomten last edited by

              @mrjj said in QStandardPaths::ApplicationsLocation strange path:

              This is an application-specific directory.

              Thanks for your quick answer!
              Yes, I have read
              "Returns the directory containing the user applications (either executables, application bundles, or shortcuts to them). This is a generic value. Note that installing applications may require additional, platform-specific operations. Files, folders or shortcuts in this directory are platform -specific. "

              I work in Linux. Make a program that looks for dead .desktop files. And removes them.

              Can be solved with

              path.truncate (path.lastIndexOf (QChar ( '/')));
              path.append ("/ applications");
              

              It just feels a little weird. But maybe it's something I do not understand.

              posktomten

              B 1 Reply Last reply Reply Quote 0
              • B
                Bonnie @posktomten last edited by

                @posktomten
                I think what you need is not AppDataLocation but ApplicationsLocation

                1 Reply Last reply Reply Quote 3
                • posktomten
                  posktomten @mrjj last edited by

                  @mrjj

                  Aha!
                  Thank you very much and I apologize. You should always read the documentation carefully before asking!
                  Thank you everyone on this friendly forum!
                  Ingemar Ceicer

                  posktomten

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post