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 and edit the doc or docx file in qt?
Forum Updated to NodeBB v4.3 + New Features

How to open and edit the doc or docx file in qt?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 3.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.
  • P Offline
    P Offline
    Puzzlesaur
    wrote on last edited by
    #1

    How can i do to create an editor which can open and edit doc or docx file in a widget? Is there any existing tools to do this?
    I try to use the "Abiword" , but it seems to be paused. so I want another one.
    Please give me some advice.

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

      Hi
      You could use LibreOffice. it edits word docs really well.

      Depending on your real requirements there is also the option of parsing the docx yourself since its xml.

      However, i have not seen a nice Qt widget that can just edit Docx Files and
      doc files that are binary are even more pain.

      P 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        You could use LibreOffice. it edits word docs really well.

        Depending on your real requirements there is also the option of parsing the docx yourself since its xml.

        However, i have not seen a nice Qt widget that can just edit Docx Files and
        doc files that are binary are even more pain.

        P Offline
        P Offline
        Puzzlesaur
        wrote on last edited by
        #3

        @mrjj thanks for your advice.

        but the libreoffice is too large , i don't need open or edit the xlsx、 ppt file.
        I think it's a big challange to edit the libreoffice source code .

        overall what I want to say are much more thanks.

        mrjjM KroMignonK 2 Replies Last reply
        0
        • P Puzzlesaur

          @mrjj thanks for your advice.

          but the libreoffice is too large , i don't need open or edit the xlsx、 ppt file.
          I think it's a big challange to edit the libreoffice source code .

          overall what I want to say are much more thanks.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Puzzlesaur

          Hi
          Yeah i think its a huge task to separate writer.exe code to be only about
          docx/doc. You could just spawn it with QProcess from your app.

          But what types of word docs do you need to handle ?

          If any word doc must be editable then i doubt its possible directly in a Qt app with out word being installed.

          I assume you want to do this without having MS office installed ?
          as else QAxWidget can be used.

          P 1 Reply Last reply
          1
          • P Puzzlesaur

            @mrjj thanks for your advice.

            but the libreoffice is too large , i don't need open or edit the xlsx、 ppt file.
            I think it's a big challange to edit the libreoffice source code .

            overall what I want to say are much more thanks.

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by KroMignon
            #5

            @Puzzlesaur said in How to open and edit the doc or docx file in qt?:

            but the libreoffice is too large , i don't need open or edit the xlsx、 ppt file

            Perhaps you could take a look at DuckX.
            Here extract form GitHub project page:

            DuckX was created when I was looking for a C++ library which can properly parse MS Word .docx files, but couldn't find any

            I don't know if it really works and how good it is...

            Good luck

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            1 Reply Last reply
            4
            • mrjjM mrjj

              @Puzzlesaur

              Hi
              Yeah i think its a huge task to separate writer.exe code to be only about
              docx/doc. You could just spawn it with QProcess from your app.

              But what types of word docs do you need to handle ?

              If any word doc must be editable then i doubt its possible directly in a Qt app with out word being installed.

              I assume you want to do this without having MS office installed ?
              as else QAxWidget can be used.

              P Offline
              P Offline
              Puzzlesaur
              wrote on last edited by
              #6

              @mrjj said in How to open and edit the doc or docx file in qt?:

              Hi
              Yeah i think its a huge task to separate writer.exe code to be only about
              docx/doc. You could just spawn it with QProcess from your app.
              But what types of word docs do you need to handle ?
              If any word doc must be editable then i doubt its possible directly in a Qt app with out word being installed.
              I assume you want to do this without having MS office installed ?
              as else QAxWidget can be used.

              I want to do this task on Linux system. so I think ActiveX may not work with me.

              JonBJ 1 Reply Last reply
              0
              • P Puzzlesaur

                @mrjj said in How to open and edit the doc or docx file in qt?:

                Hi
                Yeah i think its a huge task to separate writer.exe code to be only about
                docx/doc. You could just spawn it with QProcess from your app.
                But what types of word docs do you need to handle ?
                If any word doc must be editable then i doubt its possible directly in a Qt app with out word being installed.
                I assume you want to do this without having MS office installed ?
                as else QAxWidget can be used.

                I want to do this task on Linux system. so I think ActiveX may not work with me.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @Puzzlesaur
                Yes, you won't be able to use QAx... anything under Linux.

                Looks like your only starting point is @KroMignon's DuckX link. A docx file is basically a zipped file containing XML. That's why that code uses a zip library to unzip/zip and an XML library to read/write the XML.

                I think you'll find it only handles the very simplest of docx files, maybe with some paragraphs and some tables. I don't think it will handle anything more complicated than that without you understanding the XML in docx files and expanding the code to deal with what you want on a case-by-case basis.

                If you are writing your Qt program in Python/PyQt/PySide (are you? :) ) a more comprehensive library would be Python's own python-docx. Just looking through its code would give you an idea of how much more there is to handle than DuckX seems to provide....

                1 Reply Last reply
                2

                • Login

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