[Qt-interest] how to capture the QProcess output?

Thiago Macieira thiago at kde.org
Tue Sep 27 13:51:29 CEST 2011


On Tuesday, 27 de September de 2011 16:53:25 Muthulingam Ammaiappan wrote:
> Hi Friends,
> 
> i wanted to capture the QProcess output and show....
> 
> here is the code snippet ....

Could you please avoid inserting formatting in plain text? Obviously those 
asterisks below aren't part of the source code.

> *QString svnprogram = "./bin/svn.exe";*
> 
> *    QProcess *proc1 = new QProcess( this );*
> 
> *    proc1->setWorkingDirectory(workingdirpath);*
> 
> *    proc1->startDetached(svnprogram,arguments,workingdirpath);*
> 
> *    proc1->waitForFinished();*
> 
> *    //    proc1->terminate();*
> 
> *    QByteArray barray = proc1->readAll();*
> 
> *    QString outstr(barray);*
> 
> *    qDebug()<<outstr<<endl;*
> 
> 
> here svn.exe is called and it works fine... but it did not show the output
> in qDebug()...
> 
> can anyone please help me to fix this problem..

Your error was to use startDetached. That's a static function. Unlike Java, 
C++ does let you use the context of an object to call a static function. But 
to be on the safe side, you should have written:

	QProcess::startDetached(svnprogram, arguments, workingdirpath);

if you had done that, you'd have noticed that you never started a process in 
proc1. That means startDetached is the wrong function to use. You simply 
wanted start().

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110927/46f1850a/attachment.bin 


More information about the Qt-interest-old mailing list