Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess cannot read output while the remote process is still running

QProcess cannot read output while the remote process is still running

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GSc_Dev
    wrote on last edited by aha_1980
    #1

    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

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by dheerendra
      #2

      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);
      }
      

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved