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. QStandardPaths::ApplicationsLocation strange path

QStandardPaths::ApplicationsLocation strange path

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 589 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.
  • posktomtenP Offline
    posktomtenP Offline
    posktomten
    wrote on last edited by
    #1

    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

    mrjjM 1 Reply Last reply
    0
    • posktomtenP posktomten

      @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.

      B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #5

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

      1 Reply Last reply
      3
      • posktomtenP posktomten

        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.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @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.

        posktomtenP 1 Reply Last reply
        3
        • B Offline
          B Offline
          Bonnie
          wrote on last edited by
          #3

          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
          4
          • posktomtenP Offline
            posktomtenP Offline
            posktomten
            wrote on last edited by
            #4

            @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
            0
            • posktomtenP posktomten

              @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.

              B Offline
              B Offline
              Bonnie
              wrote on last edited by
              #5

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

              1 Reply Last reply
              3
              • mrjjM mrjj

                @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.

                posktomtenP Offline
                posktomtenP Offline
                posktomten
                wrote on last edited by
                #6

                @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
                1

                • Login

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