PDA

View Full Version : QProcess pipes problem



benacler
7th December 2007, 18:40
Hi folks,

I'm relatively new to QT and I'm going nut with a weird problem. I'm using Qt 4.3.1. what i want to do is spawning a process and collect it's output to a child window, that's the code I'm executing:

QProcess* proc = new QProcess(this);
proc->setProcessChannelMode(QProcess::MergedChannels);
connect(proc,SIGNAL(finished(int,QProcess::ExitSta tus)), this, SLOT(procFinished(int,QProcess::ExitStatus)));
connect(proc,SIGNAL(readyRead()), this, SLOT(pipeData()));
proc->start(app,QStringList() << "-v" << "3");

the pipeData slot just read using readAllStandardOutput() and concatenate it in the view.

the problem is that I receive only ONE signal with approx 4K of data, after that one, I don't get any activity further. The process I spawned has its own logging system , so I can verify that's effectively running and that's effectively dumping more data, but nothing comes from the pipes...

any suggestion ?

Thanks :)

wysota
7th December 2007, 18:54
How about using readAll() instead of readAllStandardOutput()? Maybe that's a problem after using MergedChannels...

benacler
7th December 2007, 18:57
there's no difference....still get only 4K of data then it stops.

wysota
7th December 2007, 18:58
Could we see your pipeData() slot?

benacler
7th December 2007, 19:02
void ServiceControl::pipeData() {

if (proc) {
QByteArray data = proc->readAll(); // ReadAll as you suggested
if (serviceMonitor) serviceMonitor->addBytes(data);
}

}

wysota
7th December 2007, 19:22
A potential problem is that you create the process and assign it to a local variable "proc" that is in your previous snippet of code istead of the "proc" member variable of the class and contents of if don't get executed.

benacler
7th December 2007, 19:30
I apologize, the output from my process isn't flushed, problem solved ;)