0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. But I have one question. readAllStandardOutput returns QByteArray. If program will write - (7\n67\n78\n), what format will be qbytearray?
It will have exactly that format. You can create a QString from a QByteArray, or create a QBuffer from it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.