QProcess cannot read output while the remote process is still running
-
Re: Qprocess show stdoutput only on ending of excecution.
I refer to the older topic above and have to say, I have the same problem. I'm not new for C++ and also not for Qt 5.x and in my job I have to solve that problem with a deadline but although searching in internet so many forum and spending some nights with many trials I did not find a solution so that I think the problem might be QProcess itself.
Best and easy example (like in the old forum above):
QString file = "ping";
QStringList arguments << "192.168.0.1"; // or any other address
process->start(file,arguments);This command (ping xxxxx) is running very good in any Standard Linux Terminal.
But could somebody run it by using QProcess (I don't mean the ping itself but the command-line output)? - Problem is that you get the output all only when the remote process is ended OR when you close the write channel of QProcess (but after closing it you cannot open it again (see Qt-Reference for QProcess) for your still running remote process - but in my case this is urgently needed because I have to send to the remote process AT RUNTIME requested inputs from the user.
I tried every signal-slot variant, I did subclass QProcess to disable input/output buffering (and to get more near to standard I/O functionality) but no success at all.
If you need more explanation please just read the posting above around one year ago. You can find 100 postings in different forum which mention to same problem without solution.
Would be nice if some stuff of Qt would also say something.If I would find any solution I will offer it here.
Bye, GSc_Dev
-
We are using the ping and getting the output. Here the sample.
void MyWidget::on_pushButton_clicked() { proc = new QProcess; QString pingMe = "ping 192.168.0.2"; proc->start(pingMe); proc->waitForStarted(1000); qDebug() << " Started the process" <<endl; connect(proc,SIGNAL(readyRead()),this,SLOT(readData())); } void MyWidget::readData() { QString text = ui->textEdit->toPlainText(); qDebug() << " Current Text =" << text <<endl; text = text + proc->readAll(); qDebug() <<text << endl; ui->textEdit->setPlainText(text); }