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. How to open a text document( .doc or other) using Qt in linux

How to open a text document( .doc or other) using Qt in linux

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 3.5k 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.
  • D Offline
    D Offline
    Dcqt
    wrote on last edited by
    #1

    Hi,
    How can i open a document from the program , basically the document is kind of manual for our product.
    I actually want to create an Help kind of interface where the instructions are stored, but time being just openning a doc is enough.

    Regards,
    Dcqt

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      you may want to check out "Qt's help framework":http://qt-project.org/doc/qt-4.8/qthelp-framework.html.

      But as you said for the first time "this":http://qt-project.org/doc/qt-5.0/qtgui/qdesktopservices.html#openUrl would be enough for you:
      @
      QDesktopServices::openUrl( QUrl::fromLocalFile("<path-to-file>") );
      @

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

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

        Run LibreOffice with QProcess. If you really want to parse and properly display doc files, you need to write your own parser.

        Much better idea is to use HTML help with QtWebKit, or compile QCH documentation. Doc as a filetype is deprecated, plus it's not an open standard like odf.

        (Z(:^

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Dcqt
          wrote on last edited by
          #4

          [quote author="raven-worx" date="1371728973"]you may want to check out "Qt's help framework":http://qt-project.org/doc/qt-4.8/qthelp-framework.html. But as you said for the first time "this":http://qt-project.org/doc/qt-5.0/qtgui/qdesktopservices.html#openUrl would be enough for you: @ QDesktopServices::openUrl( QUrl::fromLocalFile("<path-to-file>") ); @[/quote]
          Thanks a lot,
          Its working for files which have only text, but i have few screen shot images in my doc.

          I am getting following error.

          gvfs-open :file usermanual.doc :error opening location :operation not supported.

          is there any solution for this.

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            how does the returned value of QUrl::fromLocalFile() look like?
            A quick look up in the internet stated that "gvfs-open" has problems opening urls that have "% 2F" in it.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Dcqt
              wrote on last edited by
              #6

              [quote author="sierdzio" date="1371729006"]Run LibreOffice with QProcess. If you really want to parse and properly display doc files, you need to write your own parser. Much better idea is to use HTML help with QtWebKit, or compile QCH documentation. Doc as a filetype is deprecated, plus it's not an open standard like odf.[/quote]

              Thanks very much..
              i QProcess with libreoffice... and it opened doc with images also.

              I will look into help stuff afterwards..

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Dcqt
                wrote on last edited by
                #7

                [quote author="raven-worx" date="1371734109"]how does the returned value of QUrl::fromLocalFile() look like? A quick look up in the internet stated that "gvfs-open" has problems opening urls that have "% 2F" in it.[/quote]

                no just

                gvfs-open :file usermanual.doc :error opening location :operation not supported

                there is no "% 2F" in it.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  Dcqt
                  wrote on last edited by
                  #8

                  is there any way i can add reputation or some thing here

                  1 Reply Last reply
                  0
                  • raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by
                    #9

                    what i meant was the return value of QUrl::fromLocalFile() ... the value you pass to QDesktopServices::openUrl()

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    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