[Interest] Qt and bash scripts

R. Reucher rene.reucher at batcom-it.net
Sun Jul 1 14:25:58 CEST 2012


On Sunday 01 July 2012 14:12:50 Phil wrote:
> On 01/07/12 21:38, Thiago Macieira wrote:
> >> I had also tried start() but the output still goes to the console. Is it
> >> possible to have the directory list inserted into a string or string
> >> list?
> > 
> > Please show us the code you used when you used start().
> 
> {
>      QProcess myProcess;
>      QString str;
> 
>      myProcess.start( "ls" );
> 
>      if (!myProcess.waitForFinished())
It should work, but it's blocking (which is not nice)... you should make use 
of QProcess's asnychronous operation.

>           qDebug() << "Make failed:" << myProcess.errorString();
>       else
>      {
>           qDebug() << "Make output:" << myProcess.readAll();
> 
>           str = myProcess.readAll();
Use QProcess::readAllStandardOutput() to read from the process's stdout 
channel:
http://qt-project.org/doc/qt-4.8/qprocess.html#readAllStandardOutput

Use QProcess::readAllStandardError() to read from stderr:
http://qt-project.org/doc/qt-4.8/qprocess.html#readAllStandardError

HTH, René
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120701/5c4a1fec/attachment.html>


More information about the Interest mailing list