[Qt-interest] QProcess, stdin and Windows

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


well, I found it. In every QProcess.write(str), str should be ended with
'\n".

2009/4/23 Dong Tiger <idlecat511 at gmail.com>

> 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/704b12ed/attachment.html 


More information about the Qt-interest-old mailing list