Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, January 2007
why qprocess does not emit readyRead ?


Message 1 in thread

Hi, All,
   After doing
    QProcess *proc = new QProcess(this);
    proc->start("python", QStringList() << "-i" );
    proc->write("2+3");
   When will readyRead signal send?
   Is it possible to repeat the write?
Thanks

LaoDa



--
 [ signature omitted ] 

Message 2 in thread

Honglin Ye schrieb:
> Hi, All,
>    After doing
>     QProcess *proc = new QProcess(this);
>     proc->start("python", QStringList() << "-i" );
>     proc->write("2+3");
>    When will readyRead signal send?
>    Is it possible to repeat the write?

In the code above... NEVER! You have not connected to this signal.

And I'm not sure if you understood the semantic of "ready read" (since
you're asking whether it is "possible to repeat the WRITE"): the signals
readyReadStandardOutput (respective readyReadStandardError) are send
whenever there is data available to READ (sic!). In other words: when
the process "python" has SENT something to your application. Whatever
YOU sent to "python" is irrelevant in this context (as far as "ready
read" is concerned).

Off course, the "python" process might only send something to you if you
have send a request to it...

Also note that you're not doing any error checks in your code above (too
simplified from your actual code?), so it could be that "python" is not
in your PATH, not yet started (see waitForStarted() and/or the signals
started()/error()) etc. etc.

I suggest you read the docs about QProcess again, it's all explained there.

Good luck, Oliver

--
 [ signature omitted ]