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] Monitoring multiple processes using QProcess

[SOLVED] Monitoring multiple processes using QProcess

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.6k Views
  • 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.
  • W Offline
    W Offline
    WilliamU
    wrote on 5 Apr 2011, 16:42 last edited by
    #1

    Hello,

    I want to write an application that will launch multiple instances of the same executable which of course is easy enough. But I also need to read their unique stdout and stderr streams on their signals. Is this possible? If it is I would really appreciate a few pointers on how to go about this.

    --
    Regards,

    William

    Regards,

    William

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 5 Apr 2011, 19:35 last edited by
      #2

      You create a new QProcess object for each of the processes (using new and pointers, no stack allocation, as the process is destroyed once the variable is out of scope). So you have access to the individual input and output channels. Just keep the pointers and organize them so that you know which is which (e.g. using a hash table or a list).

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

      1 Reply Last reply
      0
      • W Offline
        W Offline
        WilliamU
        wrote on 5 Apr 2011, 20:07 last edited by
        #3

        Thank's Volker, that bit I understand but what about the signal handlers wouldn't I need one for each of the processes? Or if I could have a single one to handle all processes how would I know which process raised the signal?

        --
        Regards,

        William

        Regards,

        William

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on 5 Apr 2011, 20:24 last edited by
          #4

          One QProcess instance is needed per process. The signals of a QProcess can be mapped to a slot (also of amny QProcess instances to one slot).

          To seperate, which object was sending the signal, you can use QObject::sender() or the QSignalMapper class.

          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
          • W Offline
            W Offline
            WilliamU
            wrote on 5 Apr 2011, 21:34 last edited by
            #5

            Gerolf, this is exactly what I wanted to hear, thank you both for your input, I'll do some reading.

            --
            Thank you,

            William

            Regards,

            William

            1 Reply Last reply
            0

            1/5

            5 Apr 2011, 16:42

            • Login

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