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. Differences: QDesktopServices vs QStandardPaths

Differences: QDesktopServices vs QStandardPaths

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 7.0k 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.
  • C Offline
    C Offline
    ChrisW67
    wrote on last edited by
    #1

    Can anyone tell me if the following differences between the paths returned by Qt 4.8 QDesktopServices and 5.1RC QStandardPaths are intentional or bug-worthy? (They are certainly annoying either way)

    @
    #include <QtCore>
    #include <QDesktopServices>

    int main(int argc, char **argv)
    {
    QCoreApplication app(argc, argv);
    app.setOrganizationName("ExampleOrg");
    app.setOrganizationDomain("example.com.au");
    app.setApplicationName("ExampleApp");
    #if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
    #else
    QString paths = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
    #endif
    qDebug() << qVersion() << paths;
    return 0;
    }
    @
    Outputs under different Qt versions on 64-bit Linux:
    @
    4.8.4 "/home/chrisw/.local/share/data/ExampleOrg/ExampleApp"
    5.1.0 ("/home/chrisw/.local/share/ExampleOrg/ExampleApp", "/usr/share/ExampleOrg/ExampleApp", "/usr/local/share/ExampleOrg/ExampleApp", "/usr/share/ExampleOrg/ExampleApp")
    @
    Note the extra "data" directory in the Qt4 path.

    This means my ported Qt4-based code, when built with Qt5, looks in the wrong location for data that was previously installed/generated in the DataLocation on the deployed machine.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Quite a strange case: it's not necessarily a bug, as it does return standard location. It would have been a regression, but the name of the class has changes, so technically it's a different thing ;) Funny.

      Seems like a good candidate for a bug in Jira or at least a discussion on dev mailing list. The only thing is that if it's fixed now (say, the path is reverted back to the one reported by Qt4), it will cause a regression against Qt 5.0...

      (Z(:^

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dbzhang800
        wrote on last edited by
        #3

        IMO, this is not a bug. If you want to make it compatible with Qt4, you can still use QDesktopServices::storageLocation(QDesktopServices::DataLocation)

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          Yes, but ultimately that deprecated function will go away and the problem remains.

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

            You can also use QStandardPaths::writableLocation(GenericDataLocation) + "data/ExampleOrg/ExampleApp" if you never want to move the data out of there.

            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