I have problem when I am deleting QProcesses and I dont get any output. If I comment out deleteLater() method to delete processes I get right output in the form of string as expected. I have tried to use delete and deleteLater to delete processes. But something is still going wrong. I have created two seperate process to read data from external scripts. I am using QT3.
//Declared member Functions globally.
QString CMainTemplate
::CreateControls()
{
lineEdit->setText(GetFirstProcess());
lineEdit2->setText(GetSecondProcess());
}
//...FIRST PROCESS
QString CMainTemplate
::GetFirstProcess()
{
//Add the arguments
process1->addArgument( "/bash" );
process->addArgument("GetFirstScript");
if ( !process->start() )
{
qDebug("ERROR: First Process Never Started");
process->deleteLater();
}
connect(process, SIGNAL(readyReadStdout()), this, SLOT(readFirstProcess()));
return strFirstProcess;
}
//...SECOND PROCESS
QString CMainTemplate
::GetSecondProcess()
{
//Add the arguments
process1->addArgument( "/bash" );
process1->addArgument("GetSecondScript");
if ( !process1->start() )
{
qDebug("ERROR: Second Process Never Started");
process1->deleteLater();
}
connect(process1, SIGNAL(readyReadStdout()), this, SLOT(readSecondProcess()));
return strSecondProcess;
}
//=====================SLOTS TO READ STD OUT ===================================================
void CMainTemplate::readFirstProcess()
{
QString str
= process
->readStdout
() ;
strFirstProcess = str;
process->deleteLater();
}
void CMainTemplate::readSecondProcess()
{
QString str
= process1
->readStdout
() ;
strSecondProcess = str;
process1->deleteLater();
}
//Declared member Functions globally.
QString strFirstProcess;
QString strSecondProcess;
QProcess process1;
QProcess process2;
QString CMainTemplate::CreateControls()
{
lineEdit->setText(GetFirstProcess());
lineEdit2->setText(GetSecondProcess());
}
//...FIRST PROCESS
QString CMainTemplate::GetFirstProcess()
{
process= new QProcess(this);
//Add the arguments
process1->addArgument( "/bash" );
process->addArgument("GetFirstScript");
if ( !process->start() )
{
qDebug("ERROR: First Process Never Started");
process->deleteLater();
}
connect(process, SIGNAL(readyReadStdout()), this, SLOT(readFirstProcess()));
return strFirstProcess;
}
//...SECOND PROCESS
QString CMainTemplate::GetSecondProcess()
{
process1= new QProcess(this);
//Add the arguments
process1->addArgument( "/bash" );
process1->addArgument("GetSecondScript");
if ( !process1->start() )
{
qDebug("ERROR: Second Process Never Started");
process1->deleteLater();
}
connect(process1, SIGNAL(readyReadStdout()), this, SLOT(readSecondProcess()));
return strSecondProcess;
}
//=====================SLOTS TO READ STD OUT ===================================================
void CMainTemplate::readFirstProcess()
{
QString str = process->readStdout() ;
strFirstProcess = str;
process->deleteLater();
}
void CMainTemplate::readSecondProcess()
{
QString str = process1->readStdout() ;
strSecondProcess = str;
process1->deleteLater();
}
To copy to clipboard, switch view to plain text mode
Bookmarks