PDA

View Full Version : QProcess



bashamehboob
16th May 2008, 17:53
Hi ALL,

I am using Qt4.2.3.

In my code , I have started a QProcess and reading Stderr and posting it to the GUI.While reading Stderr at one condition i have to start another QProcess and read Stderr.As Follows.


void Config::readFromStderr()
{
while(( length = proc->readLine(buf,sizeof(buf))) != -1 && !(START_FLAG))
{
dat = (QString)buf;

if(dat.indexOf(" Manager configuration file loaded", 0 , Qt::CaseInsensitive) != -1)
{
proc1 = new QProcess(this);
connect(proc1, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr1()));
proc1->start(home1,list1,QIODevice::ReadWrite);
}
}}

first time if i run , first process is running and after that second process is running successfully and i can read the data from Stderr from both the processes.

second time if i run, first process is running , but i can't read the data from Stderr.
Why is that i can't read the data from Stderr ??:confused:

jaca
16th May 2008, 18:45
void Config::readFromStderr()
{
while(( length = proc->readLine(buf,sizeof(buf))) != -1 && !(START_FLAG))
{
dat = (QString)buf;

if(dat.indexOf(" Manager configuration file loaded", 0 , Qt::CaseInsensitive) != -1)
{
proc1 = new QProcess(this);
connect(proc1, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr1()));
proc1->start(home1,list1,QIODevice::ReadWrite);
}
}}


To start proc1 you should test whether the implementation proc ended. Use:


if (proc->waitForFinished())
proc1->start(home1,list1,QIODevice::ReadWrite);

bashamehboob
17th May 2008, 02:29
Hi ,

I require proc to be in running state because, After starting proc1, it would be communicating with proc.

Is this correct way of doing ??
Or I am going wrong ??

jaca
17th May 2008, 22:04
You can put here as you are stating the proc?
put a little more than code because I am not well understood.