PDA

View Full Version : QProcess & Working with External Programs



jstippey
17th December 2010, 19:46
Hey guys,

I am looking to trigger an external program from my program in QT. However, this program is run through a command on Xterm and I need to include a reroute > to get the proper output File.

e.x tifftopnm picturefile.tiff < picturefile.pnm

Qprocess won't handle this since I am handing a Shell command to reroute. Is there an easy way to get around this or am I going about this wrong? Any help is greatly appreciated.

Thank you guys,

wysota
18th December 2010, 00:34
This should work:

QProcess *proc = new QProcess(...);
proc->setStandardOutputFile("picturefile.pnm"); // seems you want ">" and not "<"
proc->start("tifftopnm", QStringList() << "picturefile.tiff");

jstippey
20th December 2010, 21:04
Wysota,

Thank you for taking the time to reply. I am pretty new to QT and had been focused so much on that, i failed to see my mistake in Linux syntax. One quick question for you, before I got a response I had changed my code to call a statement ( "tifftopnm filename.tiff > filename.pnm") . Is there any drawback to using the statement () expression instead of creating a QProcess?