<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000099">
<font size="-1"><font face="Bitstream Vera Sans">Dear PyKDE Members<br>
<br>
I'm opening a new QThread which launches a command-line archiver (7z)
in a QProcess (called 'pArc').<br>
<br>
I'm using following code block within that thread:<br>
</font></font>
<blockquote><font face="Bitstream Vera Sans Mono" size="-1">while not
pArc.waitForFinished(250) :</font><font face="Bitstream Vera Sans Mono"><br>
  </font><font face="Bitstream Vera Sans Mono" size="-1">    if
pArc.waitForReadyRead(100) :</font><font face="Bitstream Vera Sans Mono"><br>
  </font><font face="Bitstream Vera Sans Mono" size="-1">       
sArcData = QtCore.QString(pArc.readData(512))</font><font
 face="Bitstream Vera Sans Mono"><br>
  </font><font face="Bitstream Vera Sans Mono" size="-1">        print
"Output = " + str(sArcData)</font><font face="Bitstream Vera Sans Mono"><br>
  </font><font face="Bitstream Vera Sans Mono" size="-1">    else :</font><font
 face="Bitstream Vera Sans Mono"><br>
  </font><font face="Bitstream Vera Sans Mono" size="-1">        print
"Nothing"</font><font face="Bitstream Vera Sans Mono"><br>
  </font></blockquote>
<font size="-1"><font face="Bitstream Vera Sans"><br>
While the (large) files are being archived, "Nothing" is printed to the
screen several times.  When the process is finished, "Output = ..." is
then printed.  However, I know that 7z prints data to its stdout while
the archiving process is happening (i.e. it doesn't just wait until it
has finished).  I want to update a QProgressBar based on the output
from 7z, so I can't wait until it has finished otherwise this defeats
the purpose of the QProgressBar.<br>
<br>
</font></font><font size="-1"><font face="Bitstream Vera Sans">The
PyQt4 documentation has this to say:<br>
</font></font>
<blockquote><font size="-1"><font face="Bitstream Vera Sans">You also
have the option of forwarding the output of the running process </font></font><font
 size="-1"><font face="Bitstream Vera Sans">to the calling, main
process, by passing ForwardedChannels as the argument.</font></font><br>
  <br>
  <font size="-1"><font face="Bitstream Vera Sans">QProcess.ForwardedChannels:
QProcess forwards the output of the running </font></font><font
 size="-1"><font face="Bitstream Vera Sans">process onto the main
process. Anything the child process writes to its </font></font><font
 size="-1"><font face="Bitstream Vera Sans">standard output and
standard error will be written to the standard </font></font><font
 size="-1"><font face="Bitstream Vera Sans">output and standard error
of the main process.</font></font><br>
</blockquote>
<br>
<font size="-1"><font face="Bitstream Vera Sans">So, I then added this
line before the above code block:<br>
</font></font>
<blockquote><font face="Bitstream Vera Sans Mono" size="-1">pArc.setReadChannelMode(QtCore.QProcess.ForwardedChannels)</font><br>
</blockquote>
<font size="-1"><font face="Bitstream Vera Sans"><br>
While the file is being archived, I can now correctly see the standard
output being progressively printed to the screen.  But how do I read
this output since it is no longer associated with my QProcess?  How</font></font><font
 size="-1"><font face="Bitstream Vera Sans"> do I access the standard
output of this 'main' process?<br>
<br>
Thanks for your help.<br>
<br>
<br>
Chris<br>
<br>
</font></font>
</body>
</html>