开发者

Howto call external program and get it's output from another program

开发者 https://www.devze.com 2023-02-06 20:33 出处:网络
Howto do this in c++: Suppose that program A is a command line tool with some inputs (for example file paths and a number), according to it\'s inputs, it may get some other parameters during runtime.

Howto do this in c++:

Suppose that program A is a command line tool with some inputs (for example file paths and a number), according to it's inputs, it may get some other parameters during runtime. (if(condithin) cin<<something) I'd like to call A from another program B and want to see complete output of A during it's runnin开发者_StackOverflow中文版g. A's inputs must be entered (if necessary). B is a gui tool written with Qt and A must be shown in a plain text area and it's inputs must be shown in same place (like a console client).

I just don't know where to start. Reading something about IPC didn't help. I know it's possible because I see Dolphin's console window and python interpreter in Eric IDE...


use QProcess::execute method to start running A. you can form the argument list from B to pass to A. Use QProcess::readAllStandardOutput () to read the output of the process and display in B.


Since you use Qt, using QProcess is probably the best way to do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消