[Interest] Qt and bash scripts

Phil phil_lor at bigpond.com
Sun Jul 1 14:12:50 CEST 2012


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())
          qDebug() << "Make failed:" << myProcess.errorString();
      else
     {
          qDebug() << "Make output:" << myProcess.readAll();

          str = myProcess.readAll();
          qDebug() << "string = " << str;

	 QByteArray array = myProcess.readAllStandardOutput();

     	 qDebug() << "array size = " << array.size();

     }
}

The string = "" and the array size = 0;

> By default, the stdout and stderr of a program launched from start() goes to
> the QProcess pipes and you can read it with the regular QIODevice and QProcess
> read functions.
>
> PS: you don't need ls to list a directory.

This is just a test example. I have a bash script that I want to add to 
my code.

-- 
Regards,
Phil



More information about the Interest mailing list