[SOLVED] Monitoring multiple processes using QProcess
-
wrote on 5 Apr 2011, 16:42 last edited by
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
-
wrote on 5 Apr 2011, 19:35 last edited by
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).
-
wrote on 5 Apr 2011, 20:07 last edited by
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
-
wrote on 5 Apr 2011, 20:24 last edited by
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.
-
wrote on 5 Apr 2011, 21:34 last edited by
Gerolf, this is exactly what I wanted to hear, thank you both for your input, I'll do some reading.
--
Thank you,William
1/5