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. [Solved] Invoking external applications to view, edit and print documents
Forum Updated to NodeBB v4.3 + New Features

[Solved] Invoking external applications to view, edit and print documents

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 4.6k 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
    d.oberkofler
    wrote on last edited by
    #1

    I was wondering what the portable Qt way (if there is one) of invoking external applications to view, edit or print arbitrary documents would be?
    I have the quite common problem that from within a Qt application I need to view, edit or print documents with the appropriate applications for each of the supported the platforms. Before using Qt this was done with (quite some) platform specific code and I would like to reduce this as much as possible.
    I had a look at QDesktopServices:: openUrl and it seems to handle the view operations quite well but printing and editing would not be covered.
    Especially the edit operations are a bit more complicated because they need to keep track of when the process ends.
    Thank you for your advice!

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      QDesktopServices::openUrl() does the bulk work for you when you want to open stuff in external applications. However, when you want to know when the used process is finished, you'll probably have to write your own implementation using QProcess. I'm afraid that will involve some platform specifics to find out which program is associated with your file.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        d.oberkofler
        wrote on last edited by
        #3

        [quote author="Franzk" date="1290671318"]QDesktopServices::openUrl() does the bulk work for you when you want to open stuff in external applications. However, when you want to know when the used process is finished, you'll probably have to write your own implementation using QProcess. I'm afraid that will involve some platform specifics to find out which program is associated with your file.[/quote]

        1. Would openUrl also be able to do the printing?
        2. Are the any examples on how to use QProcess for this?
        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          [quote author="d.oberkofler" date="1290678246"]

          1. Would openUrl also be able to do the printing?
          2. Are the any examples on how to use QProcess for this?
            [/quote]

          openUrl does not handle printing. This would be highly platform and application dependent.

          There are some uses of QProcess in
          help/remotecontrol
          help/simpletextviewer
          dbus/complexpingpong
          in the Qt sources. The API docs of "QProcess":http://doc.qt.nokia.com/4.7/qprocess.html are alos quite useful.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • E Offline
            E Offline
            erik kruyt
            wrote on last edited by
            #5

            With QProcess I can indeed start e.g. an editor, even with command arguments to start the editor and go to a specific line. I should like to open the editor in a subwindow of the application (QMdiArea), and not a detached one. Is that possible?

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              You can't put an external App in a sub window...
              Windows of executable are always top level windows, especially as the processes have seperated areas of memory. But if you need an editor and a sub window, why donÄt you use QTextEdit?

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • E Offline
                E Offline
                erik kruyt
                wrote on last edited by
                #7

                Thanks for the explanation. I now use QPlainTextEdit, and that is great. It is, however, some work to add all features you expect from an editor and I should like to give the users of my application the possibility to use the editor of their own choice.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  Then you can't use the window as child window. Then Its always a seperate process with own top level windows.

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  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