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. Opening PDF in QML (or running an external application)
Qt 6.11 is out! See what's new in the release blog

Opening PDF in QML (or running an external application)

Scheduled Pinned Locked Moved General and Desktop
12 Posts 6 Posters 6.4k Views 3 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.
  • D Offline
    D Offline
    Darkmalex
    wrote on last edited by
    #3

    [quote author="sierdzio" date="1404586826"]You have 2 systems that are built into Qt and guaranteed to work on supported platforms:

    • in C++, there is "QDesktopServices":http://qt-project.org/doc/qt-5/qdesktopservices.html#openUrl
    • in QML, there is "Qt.openUrlExternally":http://qt-project.org/doc/qt-5/qml-qtqml-qt.html#openUrlExternally-method

    You can feed those methods basically anything, and it will be opened by the native app for a given file, or the web browser.[/quote]

    Thank you, openUrlExternally() is a life saver (though I can't seem to make it work either, but nothing I would not be able to handle myself :) )

    Still, I'm curious about the 3rd question. Basicly, what I want, is a ebook reader with images and interactivity. Openning a file in an external program is the most easy and obvious one, but not elegant, and I might have problems with application owners. Since it is a project that is thought out and made entirely by me for schools and educational purposes, I have freedom to chose which format will be used for books, therefore I'm looking towards HTML (or XML) but I can't think of a way to work with those on embeded linux (that doesn't mean that that is imposible). I would be happy if someone would give me a hint on what shoud i do in this situation

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aabc
      wrote on last edited by
      #4

      Hi Darkmalex,
      I suggest you to use the Poppler lib to open and view PDF documents.

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

        [quote author="aabc" date="1404632512"]Hi Darkmalex,
        I suggest you to use the Poppler lib to open and view PDF documents. [/quote]

        Thanks. Might give it another try, because my previous attempts to work with poppler were not that good, but it still seems like the only option I have left to embed books into my app.

        1 Reply Last reply
        0
        • sierdzioS sierdzio

          You have 2 systems that are built into Qt and guaranteed to work on supported platforms:

          • in C++, there is "QDesktopServices":http://qt-project.org/doc/qt-5/qdesktopservices.html#openUrl
          • in QML, there is "Qt.openUrlExternally":http://qt-project.org/doc/qt-5/qml-qtqml-qt.html#openUrlExternally-method

          You can feed those methods basically anything, and it will be opened by the native app for a given file, or the web browser.

          S Offline
          S Offline
          Shubham Gupta
          wrote on last edited by
          #6

          @sierdzio
          When i use Qt.openUrlExternally() it gives below message.

          The specified location is not supported

          Shubham Gupta

          sierdzioS 1 Reply Last reply
          0
          • S Shubham Gupta

            @sierdzio
            When i use Qt.openUrlExternally() it gives below message.

            The specified location is not supported

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #7

            @Shubham-Gupta said in Opening PDF in QML (or running an external application):

            @sierdzio
            When i use Qt.openUrlExternally() it gives below message.

            The specified location is not supported

            What path / URL are you opening? On which Operating System? With which Qt version?

            (Z(:^

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Shubham Gupta
              wrote on last edited by
              #8

              Operating system: Linux
              Path: My local machine

              Shubham Gupta

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

                OK, but what path, specifically? Please paste the code.

                Note: that methods expects an URL, so a path should have file:// prefix.

                (Z(:^

                1 Reply Last reply
                1
                • S Offline
                  S Offline
                  Shubham Gupta
                  wrote on last edited by
                  #10

                  Like
                  Qt.openUrlExternally("file://Provisional Degree Certificate")
                  I used this.
                  and gave below error.

                  gio: file:./: Operation not supported

                  Shubham Gupta

                  jsulmJ 1 Reply Last reply
                  0
                  • S Shubham Gupta

                    Like
                    Qt.openUrlExternally("file://Provisional Degree Certificate")
                    I used this.
                    and gave below error.

                    gio: file:./: Operation not supported

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

                    @Shubham-Gupta said in Opening PDF in QML (or running an external application):

                    file://Provisional Degree Certificate

                    Try to use absolute path (I guess it is somewhere in your home directory?)
                    Also: is this a file name? There is no file extension, not sure how the system should decide how to open it?

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

                    1 Reply Last reply
                    5
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      Hi,

                      Also, you should use QUrl::fromLocalFile. It will build the proper URL.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      3

                      • Login

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