PDA

View Full Version : QProcess cross-communication



TonyInSoMD
15th May 2018, 19:30
If I have a program that starts another QProcess, can I get them to talk to each other? What I'm trying right now is: 1) QProcess *proc = new QProcess(this); 2)proc->start(program name, QStringList); I'm trying to connect signals and slots between the two but not having any luck. If that can't be done, does anybody have any suggestions on how I can pass information between the two? Even if it's a QString or QByteArray being sent/received I can work with it.

marcos.miranda
15th May 2018, 19:59
Hi, TonyInSoMD.
See if this small, compressed project at the bottom of the page can help.

"http://www.qtcentre.org/threads/67606-Call-function-of-object-within-Threads?highlight=marcos.miranda"

Remember at the bottom of the page.

Cheers,

TonyInSoMD
17th May 2018, 14:36
Thanks for the try, but that is for a thread. It won't work for a process. I need something that will run between two processes, not a thread and its parent.

superpomax
11th June 2018, 14:25
Had the same problem, download the project marcos.miranda had. I found had that you need a fifth argument when you use the function connect. I think it is because your QProcess run on the different thread than your GUI, they wont communicate if you don't make the connect through multiple thread. Here's the solution for my QProcess program :
connect(program,SIGNAL(readyReadStandardOutput()), this,SLOT(updateInfo()),Qt::DirectConnection);

Hope this will help more people

And for your post, if you still have the question. You only need 1 QProcess and the other program to write on a channel (i.e lineEdit) to communicate between both