Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Cannot load pdf in the app works only for the single file
Forum Updated to NodeBB v4.3 + New Features

Cannot load pdf in the app works only for the single file

Scheduled Pinned Locked Moved Solved QML and Qt Quick
10 Posts 3 Posters 960 Views 1 Watching
  • 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.
  • R Offline
    R Offline
    realroot
    wrote on last edited by
    #1

    This is the single file:

    import QtQuick
    import QtQuick.Pdf
    
    PdfScrollablePageView {
        id: pdfPage
        document: PdfDocument {
            id: doc
            source: "/home/user/.local/share/org/app/data/Model1/file.pdf"
            onSourceChanged: {
                console.log('DOC.SOURCE CHANGED' + doc.source)
            }
        }
    
        onStatusChanged: {
            console.log('Status changed ' + status)
        }
    
        Component.onCompleted: {
            console.log('OnCompleted status ' + status)
            console.log('OnCompleted DOC.SOURCE ' + doc.source)
        }
    }
    

    This the log when I run the app:

    qml: OnCompleted status 0
    qml: OnCompleted DOC.SOURCE /home/user/.local/share/org/app/data/Model1/file.pdf
    

    This when I run only that file wiht qml6 file.qml:

    qml: Status changed 2
    qml: OnCompleted status 2
    qml: OnCompleted DOC.SOURCE /home/user/.local/share/org/app/data/Model1/file.pdf
    qml: Status changed 1
    

    I think that status 0 is the first of https://doc.qt.io/qt-6/qml-qtquick-image.html#status-prop so No image has been set.
    I tried to set it after in Component.onCompleted and some things but when I run the app status is 0 and does not change.
    How fix it?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      realroot
      wrote on last edited by
      #10

      That means error so nothing is displayed.
      https://doc.qt.io/qt-6/qml-qtquick-image.html#status-prop

      If I use

      source: StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/qtpdfbug/qtlogo.pdf"
      

      It works.

      While this works only if I use qml6 with file and not when I launch the app.

      source: "/home/user/qtpdfbug/qtlogo.pdf"
      

      Using this always work

      source: "file:///home/user/qtpdfbug/qtlogo.pdf"
      
      1 Reply Last reply
      0
      • Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #2

        Looks like a bug. Which version of Qt are you using?

        Software Engineer
        The Qt Company, Oslo

        1 Reply Last reply
        0
        • R Offline
          R Offline
          realroot
          wrote on last edited by realroot
          #3
          qml6 -v
          Qml Runtime 6.8.0
          
          qt6-base 6.8.0-1
          qt6-declarative  6.8.0-2.2
          
          1 Reply Last reply
          0
          • Axel SpoerlA Offline
            Axel SpoerlA Offline
            Axel Spoerl
            Moderators
            wrote on last edited by
            #4

            Did it work in earlier versions of Qt?

            Software Engineer
            The Qt Company, Oslo

            1 Reply Last reply
            0
            • R Offline
              R Offline
              realroot
              wrote on last edited by
              #5

              No, note that it's the first time that I am trying this so it could be possible.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                realroot
                wrote on last edited by
                #6

                @Axel-Spoerl
                Should I open a bug or something?

                1 Reply Last reply
                0
                • Axel SpoerlA Offline
                  Axel SpoerlA Offline
                  Axel Spoerl
                  Moderators
                  wrote on last edited by
                  #7

                  Yeah, report a bug, please.

                  Software Engineer
                  The Qt Company, Oslo

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    realroot
                    wrote on last edited by realroot
                    #8

                    I made a minimal app to test this that can be used in Qt Creator.
                    https://send.trom.tf/f.php?h=2oDBNgjD&d=1&k=9971ab3cdf02f0eccc0869282e76a147

                    Running

                    qml6 Main.qml
                    

                    works but running the app has status 0.

                    jsulmJ 1 Reply Last reply
                    0
                    • R realroot

                      I made a minimal app to test this that can be used in Qt Creator.
                      https://send.trom.tf/f.php?h=2oDBNgjD&d=1&k=9971ab3cdf02f0eccc0869282e76a147

                      Running

                      qml6 Main.qml
                      

                      works but running the app has status 0.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #9

                      @realroot said in Cannot load pdf in the app works only for the single file:

                      but running the app has status 0

                      What is the problem with that?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        realroot
                        wrote on last edited by
                        #10

                        That means error so nothing is displayed.
                        https://doc.qt.io/qt-6/qml-qtquick-image.html#status-prop

                        If I use

                        source: StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/qtpdfbug/qtlogo.pdf"
                        

                        It works.

                        While this works only if I use qml6 with file and not when I launch the app.

                        source: "/home/user/qtpdfbug/qtlogo.pdf"
                        

                        Using this always work

                        source: "file:///home/user/qtpdfbug/qtlogo.pdf"
                        
                        1 Reply Last reply
                        0
                        • R realroot has marked this topic as solved on

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved