Qt Forum

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

    Differences: QDesktopServices vs QStandardPaths

    General and Desktop
    4
    5
    6731
    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.
    • C
      ChrisW67 last edited by

      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 Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        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 Reply Quote 0
        • D
          dbzhang800 last edited by

          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 Reply Quote 0
          • C
            ChrisW67 last edited by

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

            1 Reply Last reply Reply Quote 0
            • D
              dfaure last edited by

              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 Reply Quote 0
              • First post
                Last post