[Interest] Qt and bash scripts

Phil phil_lor at bigpond.com
Mon Jul 2 03:38:00 CEST 2012


On 01/07/12 22:27, Thiago Macieira wrote:
> On domingo, 1 de julho de 2012 22.12.50, Phil wrote:
>> {
>>       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;
>
> You're reading stdout three times: by default, read and readAll are connected
> to stdout. Did you mean to readAllStandardError() in the second check?
>
> I have to ask: are there any files to be listed in the current directory of the
> application?
>
> What showed up in the "Make output" line?
>

Thanks Thiago and Rene for your replies, very much appreciated.

I don't think I'm expressing my question clearly.

The "Make output" line does display the contents of the directory. 
However, what I want is to have a string or a string list to contain the 
directory listing so that I can display the directory files in a dialog 
box rather than on the console screen.

This is just a simplified example of what I'd like to achieve.

-- 
Regards,
Phil



More information about the Interest mailing list