Dear Santosh,
Thanks a lot. This beautifully solved it and everything works well now.
arguments << "-b" << "-t" << "input.txt";
myProcess->start(program, arguments);
if(myProcess->waitForStarted(5000))
{
myProcess
->setReadChannel
(QProcess::StandardOutput);
myProcess->waitForReadyRead();
QByteArray out_data
= myProcess
->readAllStandardOutput
();
qDebug() << out_string.toStdString().c_str();
cout << "results: " << out_string.toLocal8Bit().constData() << "\n";
}
else
{
qDebug() << "myProcess did not start in time";
}
QObject *parent;
QString program = "./ent";
QStringList arguments;
arguments << "-b" << "-t" << "input.txt";
QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);
if(myProcess->waitForStarted(5000))
{
myProcess->setReadChannel(QProcess::StandardOutput);
myProcess->waitForReadyRead();
QByteArray out_data = myProcess->readAllStandardOutput();
QString out_string(out_data);
qDebug() << out_string.toStdString().c_str();
cout << "results: " << out_string.toLocal8Bit().constData() << "\n";
}
else
{
qDebug() << "myProcess did not start in time";
}
To copy to clipboard, switch view to plain text mode
My last question is about this:
if(myProcess->waitForStarted(5000))
if(myProcess->waitForStarted(5000))
To copy to clipboard, switch view to plain text mode
I'm assuming it means that the system waits for 5000 ms. Does it wait starting from when the external process was started or when it finshed?
Bookmarks