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

QQuickPdfDocument cannot load a pdf file with full path including volume on windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.15.1
    • PDF
    • None
    • Windows

      Using pdfviewer example program is is not possible to load any pdf, by using open file dialog.

      As  command line parameter you can use \Users\Gunnar\Downloads\bla.pdf, but  c:\Users\Gunnar\Downloads\bla.pdf will not work.

      This is due to this code:

      void QQuickPdfDocument::setSource(QUrl source)
      {
          if (m_source == source)
              return;
      
          m_source = source;
          m_maxPageWidthHeight = QSizeF();
          emit sourceChanged();
          if (source.scheme() == QLatin1String("qrc"))
              m_doc.load(QLatin1Char(':') + source.path());
          else
              m_doc.load(source.path());
      }
      

       

       I found QTBUG-6868 which was claosed a invalid.
      QUrl ( const QString & url ) / path() problem on windows for local files

      QUrl q("file:///c:/tmp/test.txt")
      qDebug() << q.path();

      will result as a path: /c:/tmp/test.txt

       This was commented:
      tmacieir added a comment - 26 Dec '09 20:10
      There's nothing wrong with the implementation. QUrl::path() returns the path component of the URI. No one ever promised that it was a valid file path on the filesystem.
      416365416c added a comment - 16 Sep '13 18:41
      Note that to get a valid path, you can use toLocalFile() instead of path().

       

      But I think this behaviour really should be documented as also experienced Qt programmers like Shawn Rutledge do not know about this.

      It also seems to me not many people use the pdf module on windows as this bug was not detected earlier.

       

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            srutledg Shawn Rutledge
            gunnr.roth Gunnar Roth
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes