Solved Communication between Qt application via QProcess
-
Hi,
I'm trying to implement two-sided communication between 2 Qt apps,
Saw this might be possible via a main app launching the second app through a wrapped QProcess and connecting signals both ways ...What I don't get is how do I get the access from the application that is launched by the QProcess (and the other way around - how send a signal to the started application)?
Thanks.
-
I would actually just use
QLocalSocket
and trasmit data as it was a normal socket -
Hi,
If you mean sending commands and getting results you can use standard read , write channels and the signal named QProcess::readyReadStandardOutput -
I would actually just use
QLocalSocket
and trasmit data as it was a normal socket -
@kirilsagoth said in Communication between Qt application via QProcess:
Hi,
I'm trying to implement two-sided communication between 2 Qt apps,
Saw this might be possible via a main app launching the second app through a wrapped QProcess and connecting signals both ways ...What I don't get is how do I get the access from the application that is launched by the QProcess (and the other way around - how send a signal to the started application)?
Thanks.
No. Wrong way to do this. The correct way to do this is IPC or interprocess communications. pipes, shared memory, sockets, messages queues, etc. There exist several mechanisms.
Your way is fine if you have a master program that needs to spawn "existing" system commands and gather their responses, but for real IPC between two Qt apps use the mechanisms I've listed.
-
@kirilsagoth
I too would probably use @VRonin'sQLocalSocket
for this. However, if you do not want to get into how to set up sockets for this, and you are still having the parent process spawn the other process throughQProcess
, you could alternatively use the fact thatQProcess
connects the output/stdout of the parent to the child's input/stdin, and vice versa. So you can send writes from each side to reads at the other side from the start. -
@VRonin said in Communication between Qt application via QProcess:
QLocalSocket
@VRonin Thanks MAN! QLocalServer/Socket did the job beautifully.
-
@kirilsagoth said in Communication between Qt application via QProcess:
QLocalServer/Socket did the job beautifully.
So please mark your post as solved! Thanks.