[Qt-interest] About QProcess :How to read stdoutput realtime?
Princy K. V.
princy.kv at nestgroup.net
Tue May 5 15:17:31 CEST 2009
Hi,
Thanks forum..
Information in the following link solved my issues..
http://lists.trolltech.com/qt-interest/2004-08/thread00314-0.html
Thanks chandrasekar wagmare for all ur suggestions..
Thanks
Princy
Re: About QProcess :How to read stdoutput realtime?
(chandrasekar wagmare)
no not to flush your Qt code .. check the output of the external
program u
try to run from QProcess ... ex: if u are trying to run application
"a.out"
..
in "a.out" there may be any problem with stdout ...
are u using linux .. if so
run the application with this command
*a.out | less*
and check if it is printing the output in regular interval ...
On Tue, May 5, 2009 at 4:30 PM, Princy K. V.
<princy.kv at nestgroup.net>wrote:
> 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.
More information about the Qt-interest-old
mailing list