开发者

Qt program with Shell

开发者 https://www.devze.com 2023-04-10 16:28 出处:网络
I want to write a testing program. It will open a special *.tests file and test direct program with tests from the file.

I want to write a testing program. It will open a special *.tests file and test direct program with tests from the file.

I need to:

  1. Run some program. e.g ./main -testing 45 563 67
  2. Listen to result.

How I can to do it? I want to run program main with some tests开发者_如何学运维 and listen to its result.


You should ues the QProcess class to start your program.

QString program = "./main";
QStringList arguments;
arguments << "-testing" << "45" << "563" << ...;

QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);

Then you can use the waitForFinished to wait for it to finish. exitCode will give you the return code.

The readAllStandardOutput (or *Error) methods allow you to read what the process has output to the console.

0

精彩评论

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

关注公众号