How to realize the function of Inter-process Dialogue in qt
This article mainly explains "qt how to achieve inter-process dialogue function", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "qt how to achieve inter-process dialogue function" bar!
Sample code
The code on the called side is exactly the same as in yesterday's article, and only the code on the calling side is described here.
# include
# include
# include
Int main (int argc, char * argv [])
{
QCoreApplication a (argc, argv)
QProcess server
Server.start ("G:\\ Qt\\ 21070809 ProcessComm\\ ServerProcess\\ bin\\ debug\\ ServerProcess.exe"
, QStringList (); if (! server.waitForStarted ())
Return-1; QTextStream cin (stdin)
QTextStream cout (stdout)
QByteArray input
QByteArray response
While (input! = "bye\ n")
{
Cin > > input
Input + = "\ n"
Server.write (input)
Server.waitForReadyRead ()
Response = server.readLine ()
Response.replace ("\ r\ n", "")
Cout