Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QStandardPaths::ApplicationsLocation strange path



  • 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
    I think what you need is not AppDataLocation but ApplicationsLocation


  • Lifetime Qt Champion

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



  • 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>"



  • @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
    I think what you need is not AppDataLocation but ApplicationsLocation



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


Log in to reply