Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-55300

QDesktopServices::openUrl() ignores URL's fragment

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.6.2
    • 5.7.0
    • QPA: Windows
    • None
    • Windows 10 update 1607, Qt 5.7.0 mingw
    • cc517d7cd983d9444e9690353ea7ca7ee30740ef (qtbase/5.6, 16.8.2016, 5.6.2)

      Using Qt 5.7.0 on Windows 10.

      I create an URL using fromLocalFile(), then I add a fragment using setFragment(). The method toString() shows that the fragment is correctly used in the URL.

      Then, I call QDesktopServices::openUrl() on this URL. In the browser, the URL misses the fragment. This has been tested with Firefox and IE as default browsers with the same result.

      Example:

      #include <QApplication>
      #include <QDesktopServices>
      #include <QUrl>
      #include <QtDebug>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QUrl url(QUrl::fromLocalFile("C:\\Temp\\qtlmovie-user.html"));
          url.setFragment("tabTools");
          qWarning() << "Qt:" << qVersion() << "URL:" << url.toString();
          bool ok = QDesktopServices::openUrl(url);
          qWarning() << "openUrl returned" << ok;
      }
      

      Display:

      Qt: 5.7.0 URL: "file:///C:/Temp/qtlmovie-user.html#tabTools"
      openUrl returned true
      

      In the address bar of the browser, we see:

      file:///C:/Temp/qtlmovie-user.html
      

      The transmitted URL has no trailing "#tabTools" and the display is at the top of the page, not at the target anchor.

        For Gerrit Dashboard: QTBUG-55300
        # Subject Branch Project Status CR V

            kleint Friedemann Kleint
            thiel2 Thierry Lelegard
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes