timmu
15th October 2012, 12:13
I'd like to start QProcess to interact with Octave from within my code.
I never get any response because the process doesn't seem to be running. I suspect I'm using QProcess wrong.
Would you be able to help. Here's what I'm doing:
#include <QProcess>
#include "octave/oct.h"
QStringList arguments;
arguments << "--persist";
QProcess octave;
octave.setProcessChannelMode(QProcess::MergedChann els);
octave.start("/usr/bin/octave3.2", arguments);
if (octave.state() == QProcess::Running)
{
QString command = "1+2\n";
octave.write(command.toAscii());
QString answer; answer.append(octave.readAll() + "\n");
cout << "answer: " << command.toLocal8Bit().constData() << "\n";
}
octave.close();
I never get any response because the process doesn't seem to be running. I suspect I'm using QProcess wrong.
Would you be able to help. Here's what I'm doing:
#include <QProcess>
#include "octave/oct.h"
QStringList arguments;
arguments << "--persist";
QProcess octave;
octave.setProcessChannelMode(QProcess::MergedChann els);
octave.start("/usr/bin/octave3.2", arguments);
if (octave.state() == QProcess::Running)
{
QString command = "1+2\n";
octave.write(command.toAscii());
QString answer; answer.append(octave.readAll() + "\n");
cout << "answer: " << command.toLocal8Bit().constData() << "\n";
}
octave.close();