Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Pdf viewer using QDesktopServices
Forum Updated to NodeBB v4.3 + New Features

Pdf viewer using QDesktopServices

Scheduled Pinned Locked Moved Mobile and Embedded
25 Posts 4 Posters 10.0k 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.
  • C Offline
    C Offline
    ChaitraMohan
    wrote on last edited by
    #1

    Hi all,

    I am trying to display a *pdf * file using Qt.

    I used QDesktopServices for this purpose.
    @
    QString str = "/home/chaitra/Desktop/xyz.pdf";
    QDesktopServices::openUrl(QUrl(str, QUrl::TolerantMode));
    @

    Though I have Evince pdf viewer, the pdf file is being displayed on the web browser.
    While it runs I can see the following:
    Opening "/home/chaitra/Desktop/xyz.pdf" with Document Viewer (application/pdf)
    No protocol specified
    No protocol specified
    Cannot parse arguments: Cannot open display:

    Can I know why it is not displaying using the default pdf viewer. Is there any additional things that I need to do to display the pdf using the pdf viewer?

    Please help me to resolve this.

    Thanks you in advance

    [edit: added missing coding tags SGaist]

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

      Hi and welcome to devnet,

      You are using the wrong way to build a QUrl since it's a local file

      Try with:

      @
      QDesktopServices::openUrl(QUrl::fromLocalFile(str));
      @

      Hope it helps

      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
      0
      • C Offline
        C Offline
        ChaitraMohan
        wrote on last edited by
        #3

        Hi,

        I tried with:
        @QDesktopServices::openUrl(QUrl::fromLocalFile(str));@

        But I ended up with the same result. PDF is opening in web browser not using Evince.
        The error is as below:
        "Error: no "view" mailcap rules found for type "application/pdf"
        Opening "/home/chaitra/Desktop/xyz.pdf" with Document Viewer (application/pdf)
        No protocol specified
        No protocol specified
        Cannot parse arguments: Cannot open display:"

        Can I know what I need to do?

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

          Are you sure Evince is the default PDF viewer on your system ?

          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
          0
          • C Offline
            C Offline
            ChaitraMohan
            wrote on last edited by
            #5

            Ya I am sure I am using that for any pdf view.

            But I am unable to display pdf using QtUrl.

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

              Just to be sure, Evince opens when you double click on a file ?

              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
              0
              • A Offline
                A Offline
                andreyc
                wrote on last edited by
                #7

                [quote author="ChaitraMohan" date="1406523641"]
                ...
                Cannot parse arguments: Cannot open display:"
                ...
                [/quote]

                You don't run application over the network, don't you?
                In addition to SGaist question, try to open this pdf in a terminal.
                @
                xdg-open /home/chaitra/Desktop/xyz.pdf
                @

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Chaitra
                  wrote on last edited by
                  #8

                  Hi,
                  Thank you both.

                  @SGaist
                  Ya when I double click on the pdf it opens via "Evince" only.

                  @andreyc
                  No I am running my application over network. It a simple application which I have written to open the pdf file. But Its opening via web browser.

                  I tried with the below commands in terminal. The pdf open via Evince.
                  @xdg-open /home/chaitra/Desktop/xyz.pdf@

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    ChaitraMohan
                    wrote on last edited by
                    #9

                    Hi,

                    May it was a problem with Evince or what I don't know the pdf was opening via web browser instead of Evince.

                    Now I installed the Adobe pdf viewer. With the code following code pdf is opening via Adobe.

                    @QString str = "/home/chaitra/Desktop/xyz.pdf";
                    QDesktopServices::openUrl(QUrl::fromLocalFile(str));@

                    Thank you for the support.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      ChaitraMohan
                      wrote on last edited by
                      #10

                      Hi,

                      I have one question.
                      Does QDesktopServices doesnot work in embedded environment?
                      Because when I try to run the application to open in an embedded environment the following error I am getting:
                      QDesktopServices::launchwebBrowser not implemented

                      Can I know the reason for this?

                      Thank you in advance.

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

                        Hi,

                        What embedded environment ?

                        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
                        0
                        • C Offline
                          C Offline
                          ChaitraMohan
                          wrote on last edited by
                          #12

                          Hi,

                          For embedded linux.

                          I have cross compiled the Qt4.8.6 giving the following configuration options:
                          @./configure -prefix /usr/local/Qt_4.8.6 -embedded arm -platform qws/linux-x86-g++ -xplatform qws/linux-arm-linaro-g++ -static -no-mmx -no-rpath -no-3dnow -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -little-endian -qt-gfx-linuxfb -fontconfig -no-sql-mysql -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-webkit -no-qt3support -nomake examples -nomake demos -nomake docs -nomake translations -qt-freetype -qt-libjpeg -qt-libpng -gfx-transformed@

                          The Qt applications are running on the embedded linux. But when I tried to open a pdf using the QDesktopservices:
                          @QString str = "/home/chaitra/Desktop/xyz.pdf";
                          QDesktopServices::openUrl(QUrl::fromLocalFile(str));@

                          I am getting the following error when I run the Qt application:
                          QDesktopServices::launchwebBrowser not implemented

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

                            It's not an error. You don't have any desktop environment that handles file/program association so how should Qt know what to launch ? Also since you are using QWS, if you had any program able to read your pdf it should also be built to use QWS.

                            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
                            0
                            • C Offline
                              C Offline
                              ChaitraMohan
                              wrote on last edited by
                              #14

                              Hi,

                              bq. You don’t have any desktop environment that handles file/program association so how should Qt know what to launch ?

                              I dint understand your sentence. Can you tell me little details about that?

                              bq. Also since you are using QWS, if you had any program able to read your pdf it should also be built to use QWS.

                              While building Qt source what should I include so that I can get the pdf view?

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

                                Desktop Environment: KDE, Gnome, LXDE etc…
                                The file type/program association is not something that is automagical, your desktop environment has settings where this information is stored so when you double click on a document/media/whatever it opens one application. QDesktopEnvironment uses these services when available.

                                For viewing PDFs, you need to use an external library like poppler

                                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
                                0
                                • C Offline
                                  C Offline
                                  ChaitraMohan
                                  wrote on last edited by
                                  #16

                                  Yes I have Gnome Desktop environment.
                                  When I double click on the document, it opens with application also. Still when I run the application that statement pops up.

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

                                    Not on your target, otherwise you wouldn't be using QWS

                                    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
                                    0
                                    • C Offline
                                      C Offline
                                      ChaitraMohan
                                      wrote on last edited by
                                      #18

                                      On my target itself I have gnome running.
                                      When I double click on the pdf it opens using evince application.

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

                                        Then if your target is running Gnome, why do you use Qt for Embedded Linux ?

                                        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
                                        0
                                        • C Offline
                                          C Offline
                                          ChaitraMohan
                                          wrote on last edited by
                                          #20

                                          I want to run a Qt application, that opens pdf while I am running the application.

                                          1 Reply Last reply
                                          0

                                          • Login

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