まず、Qt を使用してQProcessを作成しました。
QStringList arguments;
arguments << "--persist"; //set arguments of the octave process. --persist:Go interactive after
octave.setProcessChannelMode(QProcess::MergedChannels); //set process channel
octave.start("/usr/bin/octave", arguments);//If octave has installed into any other directory this should be changed.
その後、オクターブ処理の標準入力に書き込めるようになりました。
if(octave.state()==QProcess::Starting){
octave.waitForStarted();
//TODO:should set a timeout and if timeout happens set a error report.
processWrite(command);
}
else if(octave.state()==QProcess::Running){
//TODO write Code
octave.waitForReadyRead(1000);//wait until Standered output ready
if(command.isEmpty()){
return;
}
else{
command+="\n";
octave.write(command.toUtf8());
}
}
else{
//TODO: Error reporting
}