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. Communication between Qt application via QProcess
Forum Updated to NodeBB v4.3 + New Features

Communication between Qt application via QProcess

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 6 Posters 1.3k Views 4 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.
  • K Offline
    K Offline
    kirilsagoth
    wrote on 7 Oct 2019, 14:58 last edited by
    #1

    Hi,

    I'm trying to implement two-sided communication between 2 Qt apps,
    Saw this might be possible via a main app launching the second app through a wrapped QProcess and connecting signals both ways ...

    What I don't get is how do I get the access from the application that is launched by the QProcess (and the other way around - how send a signal to the started application)?

    Thanks.

    K J 2 Replies Last reply 7 Oct 2019, 18:50
    0
    • V Offline
      V Offline
      VRonin
      wrote on 7 Oct 2019, 15:54 last edited by
      #3

      I would actually just use QLocalSocket and trasmit data as it was a normal socket

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      K 1 Reply Last reply 8 Oct 2019, 09:32
      4
      • C Offline
        C Offline
        CKurdu
        wrote on 7 Oct 2019, 15:49 last edited by
        #2

        Hi,
        If you mean sending commands and getting results you can use standard read , write channels and the signal named QProcess::readyReadStandardOutput

        You reap what you sow it

        1 Reply Last reply
        2
        • V Offline
          V Offline
          VRonin
          wrote on 7 Oct 2019, 15:54 last edited by
          #3

          I would actually just use QLocalSocket and trasmit data as it was a normal socket

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          K 1 Reply Last reply 8 Oct 2019, 09:32
          4
          • K kirilsagoth
            7 Oct 2019, 14:58

            Hi,

            I'm trying to implement two-sided communication between 2 Qt apps,
            Saw this might be possible via a main app launching the second app through a wrapped QProcess and connecting signals both ways ...

            What I don't get is how do I get the access from the application that is launched by the QProcess (and the other way around - how send a signal to the started application)?

            Thanks.

            K Offline
            K Offline
            Kent-Dorfman
            wrote on 7 Oct 2019, 18:50 last edited by
            #4

            @kirilsagoth said in Communication between Qt application via QProcess:

            Hi,

            I'm trying to implement two-sided communication between 2 Qt apps,
            Saw this might be possible via a main app launching the second app through a wrapped QProcess and connecting signals both ways ...

            What I don't get is how do I get the access from the application that is launched by the QProcess (and the other way around - how send a signal to the started application)?

            Thanks.

            No. Wrong way to do this. The correct way to do this is IPC or interprocess communications. pipes, shared memory, sockets, messages queues, etc. There exist several mechanisms.

            Your way is fine if you have a master program that needs to spawn "existing" system commands and gather their responses, but for real IPC between two Qt apps use the mechanisms I've listed.

            1 Reply Last reply
            4
            • K kirilsagoth
              7 Oct 2019, 14:58

              Hi,

              I'm trying to implement two-sided communication between 2 Qt apps,
              Saw this might be possible via a main app launching the second app through a wrapped QProcess and connecting signals both ways ...

              What I don't get is how do I get the access from the application that is launched by the QProcess (and the other way around - how send a signal to the started application)?

              Thanks.

              J Offline
              J Offline
              JonB
              wrote on 8 Oct 2019, 08:56 last edited by
              #5

              @kirilsagoth
              I too would probably use @VRonin's QLocalSocket for this. However, if you do not want to get into how to set up sockets for this, and you are still having the parent process spawn the other process through QProcess, you could alternatively use the fact that QProcess connects the output/stdout of the parent to the child's input/stdin, and vice versa. So you can send writes from each side to reads at the other side from the start.

              1 Reply Last reply
              0
              • V VRonin
                7 Oct 2019, 15:54

                I would actually just use QLocalSocket and trasmit data as it was a normal socket

                K Offline
                K Offline
                kirilsagoth
                wrote on 8 Oct 2019, 09:32 last edited by
                #6

                @VRonin said in Communication between Qt application via QProcess:

                QLocalSocket

                @VRonin Thanks MAN! QLocalServer/Socket did the job beautifully.

                P 1 Reply Last reply 8 Oct 2019, 20:31
                0
                • K kirilsagoth
                  8 Oct 2019, 09:32

                  @VRonin said in Communication between Qt application via QProcess:

                  QLocalSocket

                  @VRonin Thanks MAN! QLocalServer/Socket did the job beautifully.

                  P Offline
                  P Offline
                  Pablo J. Rogina
                  wrote on 8 Oct 2019, 20:31 last edited by
                  #7

                  @kirilsagoth said in Communication between Qt application via QProcess:

                  QLocalServer/Socket did the job beautifully.

                  So please mark your post as solved! Thanks.

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0

                  1/7

                  7 Oct 2019, 14:58

                  • Login

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