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 :
{
myProcess
->setReadChannelMode
(QProcess::MergedChannels);
connect(myProcess, SIGNAL(readyRead()), this, SLOT(SLOT_onReadyReadOut()));
myProcess->start("../../src_2/release/src_2.exe");
myProcess->write("An instruction to perform...");
}
Veilleur::Veilleur(QWidget *parent) : QObject(parent)
{
myProcess = new QProcess(this);
myProcess->setReadChannelMode(QProcess::MergedChannels);
connect(myProcess, SIGNAL(readyRead()), this, SLOT(SLOT_onReadyReadOut()));
myProcess->start("../../src_2/release/src_2.exe");
myProcess->write("An instruction to perform...");
}
To copy to clipboard, switch view to plain text mode
void Veilleur::SLOT_onReadyReadOut()
{
std::cout << "\nReading the child application, on its stdout channel : " << std::endl;
message.append(myProcess->readAllStandardOutput());
std::cout << "." << message.toStdString() << "." << std::endl;
}
void Veilleur::SLOT_onReadyReadOut()
{
std::cout << "\nReading the child application, on its stdout channel : " << std::endl;
QString message = "";
message.append(myProcess->readAllStandardOutput());
std::cout << "." << message.toStdString() << "." << std::endl;
}
To copy to clipboard, switch view to plain text mode
My "src_2" application is the following :
man.cpp :
#include <QApplication>
#include "MailChecker.h"
int main(int argc, char *argv[])
{
MailChecker * mChecker = new MailChecker();
mChecker->Check();
return app.exec();
}
#include <QApplication>
#include "MailChecker.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MailChecker * mChecker = new MailChecker();
mChecker->Check();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
MailChecker constructor :
MailChecker
::MailChecker() : QObject(){
std::cout << "Message for the parent application : I'm here !" << std::endl;
}
MailChecker::MailChecker() : QObject()
{
std::cout << "Message for the parent application : I'm here !" << std::endl;
}
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
Bookmarks