[Qt-interest] QProcess, stdin and Windows

Dong Tiger idlecat511 at gmail.com
Thu Apr 23 15:11:33 CEST 2009


Hi,

I am writing a Qt progrom, which launches another Qt program using QProcess
and talks with the child process through the child's stdin/stdout. In the
child process, I spawn a thread which keep reading stdin and the code looks
like that:

  QTextStream input(stdin, QFile::ReadOnly);
  while (1) {
    QString line = input.readLine();
    if (!line.isNull()) {
      LOG("%d:%s", line.length, line.toStdString().c_str());
      emit GotLine(line);
    }
  }

But it turns out that the thread can only read in the first line.  After
that, the thread only read in an empty string with lengh 0. But if I run the
child program directly from "cmd", it will echo everything I enter.

Any idea of that? TIA.

--
Tiger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090423/5a5e2acf/attachment.html 


More information about the Qt-interest-old mailing list