[Qt-interest] About QProcess :How to read stdoutput realtime?

Princy K. V. princy.kv at nestgroup.net
Tue May 5 13:00:20 CEST 2009


Hi,

 Sorry to interrupt  again..

I modified code ..but Start slot never invoked? Why is it so??

 

connect(process , SIGNAL(readyRead()) , process, SLOT(Start()));

 

void CMainWindow::Start()

{

QByteArray byteArray;

byteArray.resize(2000);

byteArray.clear();

fflush(stdout);

byteArray=process->readAllStandardOutput();

ui->plainTextEdit->appendPlainText(byteArray);

}

 

Thanks..

________________________________

From: chandrasekar wagmare [mailto:sekarwagmare at gmail.com] 
Sent: Tuesday, May 05, 2009 3:33 PM
To: Princy K. V.
Subject: Re: [Qt-interest] About QProcess :How to read stdoutput
realtime?

 

it's a problem of an incorrectly setup buffering method... and
you won't be able to solve this from within your calling program.
Either "patch" the program you are calling to use line buffering --
setlinebuf(stdout) -- or use fflush(stdout) every now and then in this
program. If you can't do this, then there's no way to solve it.

It's NOT a problem of QProcess or anything you could solve by any
trickery
here... I have similar issues with some of the programs that I call from
some
of my apps and there's no way around it (at least no platform
independent
one).
ex: i am using linux to run an external system call glxgears in QProcess
and i get output after ten minutes only or when the buffer filled
completly ..
        i try this one "glxgears | less" and find the problem in buffer
flush 

On Tue, May 5, 2009 at 2:43 PM, Princy K. V. <princy.kv at nestgroup.net>
wrote:

Hi,

Thanks for ur reply.

But slot is not invoked when I used these signals
readyReadStandardError <http://qprocess.html#readyReadStandardError>  ()
& readyReadStandardOutput <http://qprocess.html#readyReadStandardOutput>
(

..so I used following code snippets, this consumes lot of
time..sometimes not getting desired output..

 

void CMainWindow::Run()

{

QByteArray byteArray;

byteArray.resize(2000);

byteArray.clear();

ui->plainTextEdit->setEnabled(true);

ui->plainTextEdit->clear();

while(!Start())

{

//progress->hide();

byteArray.clear();

byteArray=process->readAllStandardOutput();

ui->plainTextEdit->appendPlainText(byteArray);

}

}

 

void CMainWindow::Start()

{

.......

process->start("xx.exe" ,arguments);

if (!process->waitForStarted())

return false;

// ui->statusBar->addPermanentWidget(progress , 0);

if(!process->waitForFinished())

{

//progress->setMinimum(0);

//progress->setMaximum(0);

//progress->show();

return false;

}

......

return true;

}

 

 

 

________________________________

 

u are using this signals right ,

void readyReadStandardError
<http://qprocess.html#readyReadStandardError>  ()

void readyReadStandardOutput
<http://qprocess.html#readyReadStandardOutput>  ()

 

On Tue, May 5, 2009 at 1:04 PM, Princy K. V. <princy.kv at nestgroup.net>
wrote:

Hi,
 I m new to Qt.I want to display datas that are written on stdoutput by
an external process on my gui. I have started external process using
Qprocess. I can display all stdoutput data by calling,
byteArray=process->readAllStandardOutput();
ui->plainTextEdit->appendPlainText(byteArray);
But my reqiurment is to display data(line by line) same time it is
written on stdoutput.i have tried many methods.so far didn't get
required output..
Please suggest me some solutions..
Thanks..
***** Confidentiality Statement/Disclaimer *****

This message and any attachments is intended for the sole use of the
intended recipient. It may contain confidential information. Any
unauthorized use, dissemination or modification is strictly prohibited.
If you are not the intended recipient, please notify the sender
immediately then delete it from all your systems, and do not copy, use
or print. Internet communications are not secure and it is the
responsibility of the recipient to make sure that it is virus/malicious
code exempt.
The company/sender cannot be responsible for any unauthorized
alterations or modifications made to the contents. If you require any
form of confirmation of the contents, please contact the company/sender.
The company/sender is not liable for any errors or omissions in the
content of this message.
***** Confidentiality Statement/Disclaimer *****

This message and any attachments is intended for the sole use of the
intended recipient. It may contain confidential information. Any
unauthorized use, dissemination or modification is strictly prohibited.
If you are not the intended recipient, please notify the sender
immediately then delete it from all your systems, and do not copy, use
or print. Internet communications are not secure and it is the
responsibility of the recipient to make sure that it is virus/malicious
code exempt.

The company/sender cannot be responsible for any unauthorized
alterations or modifications made to the contents. If you require any
form of confirmation of the contents, please contact the company/sender.
The company/sender is not liable for any errors or omissions in the
content of this message.


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




-- 
WAGMARE

***** Confidentiality Statement/Disclaimer ***** 

This message and any attachments is intended for the sole use of the
intended recipient. It may contain confidential information. Any
unauthorized use, dissemination or modification is strictly prohibited.
If you are not the intended recipient, please notify the sender
immediately then delete it from all your systems, and do not copy, use
or print. Internet communications are not secure and it is the
responsibility of the recipient to make sure that it is virus/malicious
code exempt.
The company/sender cannot be responsible for any unauthorized
alterations or modifications made to the contents. If you require any
form of confirmation of the contents, please contact the company/sender.
The company/sender is not liable for any errors or omissions in the
content of this message.***** Confidentiality Statement/Disclaimer *****


This message and any attachments is intended for the sole use of the
intended recipient. It may contain confidential information. Any
unauthorized use, dissemination or modification is strictly prohibited.
If you are not the intended recipient, please notify the sender
immediately then delete it from all your systems, and do not copy, use
or print. Internet communications are not secure and it is the
responsibility of the recipient to make sure that it is virus/malicious
code exempt.

The company/sender cannot be responsible for any unauthorized
alterations or modifications made to the contents. If you require any
form of confirmation of the contents, please contact the company/sender.
The company/sender is not liable for any errors or omissions in the
content of this message.




-- 
WAGMARE

***** Confidentiality Statement/Disclaimer ***** 

This message and any attachments is intended for the sole use of the intended recipient. It may contain confidential information. Any unauthorized use, dissemination or modification is strictly prohibited. If you are not the intended recipient, please notify the sender immediately then delete it from all your systems, and do not copy, use or print. Internet communications are not secure and it is the responsibility of the recipient to make sure that it is virus/malicious code exempt.
The company/sender cannot be responsible for any unauthorized alterations or modifications made to the contents. If you require any form of confirmation of the contents, please contact the company/sender. The company/sender is not liable for any errors or omissions in the content of this message.
***** Confidentiality Statement/Disclaimer *****  

This message and any attachments is intended for the sole use of the intended recipient. It may contain confidential information. Any unauthorized use, dissemination or modification is strictly prohibited. If you are not the intended recipient, please notify the sender immediately then delete it from all your systems, and do not copy, use or print. Internet communications are not secure and it is the responsibility of the recipient to make sure that it is virus/malicious code exempt.

The company/sender cannot be responsible for any unauthorized alterations or modifications made to the contents. If you require any form of confirmation of the contents, please contact the company/sender. The company/sender is not liable for any errors or omissions in the content of this message.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090505/73514830/attachment.html 


More information about the Qt-interest-old mailing list