[SOLVED] Monitoring multiple processes using QProcess



  • 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



  • 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).



  • 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



  • 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.



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

    --
    Thank you,

    William


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.