Hello,

I know that the QProcess problem has been discussed many times, but there is one thing I can't find on the forum : How the child application can handle the main application's instructons writted on the output channel ?



My main application creates a QProcess linked to "src_2.exe" and listen its output channel :
Qt Code:
  1. Veilleur::Veilleur(QWidget *parent) : QObject(parent)
  2. {
  3. myProcess = new QProcess(this);
  4. myProcess->setReadChannelMode(QProcess::MergedChannels);
  5. connect(myProcess, SIGNAL(readyRead()), this, SLOT(SLOT_onReadyReadOut()));
  6.  
  7. myProcess->start("../../src_2/release/src_2.exe");
  8.  
  9. myProcess->write("An instruction to perform...");
  10. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. void Veilleur::SLOT_onReadyReadOut()
  2. {
  3. std::cout << "\nReading the child application, on its stdout channel : " << std::endl;
  4. QString message = "";
  5. message.append(myProcess->readAllStandardOutput());
  6. std::cout << "." << message.toStdString() << "." << std::endl;
  7. }
To copy to clipboard, switch view to plain text mode 



My "src_2" application is the following :

man.cpp :
Qt Code:
  1. #include <QApplication>
  2.  
  3. #include "MailChecker.h"
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. QApplication app(argc, argv);
  8.  
  9. MailChecker * mChecker = new MailChecker();
  10. mChecker->Check();
  11.  
  12. return app.exec();
  13. }
To copy to clipboard, switch view to plain text mode 

MailChecker constructor :
Qt Code:
  1. MailChecker::MailChecker() : QObject()
  2. {
  3. std::cout << "Message for the parent application : I'm here !" << std::endl;
  4. }
To copy to clipboard, switch view to plain text mode 



So I would like the child application doing the same job as the parent application.
I would like it to listen the output channel of the parent, in order to give it instructions.
I can't understand how to do it, but I think it would be similar to what i've done for the parent one.

In the parent one it wasn't too difficult, cause I could create my own child application and recognize it every where : she was the "myProcess".
But in the new child application I can't access to the parent one, in order to declare a connect like :
connect(myParentProcess, SIGNAL(readyRead()), this, SLOT(SLOT_onReadyReadOut()));

And how if I could identify the "myParentProcess", where should I declare the connection ?



Thanks for your help