How to set working directory of QProcess

Thank you very much for the nice tutorial about running external program in Qt.
I would like to ask a question about QProcess.
If the external program is in different folder of the Qt code,
how should one call an external program in its own directory?

Suppose external program is in ‘C:/program_folder/test.exe’ (with its own input files in that directory.)
and the Qt code is in ‘C:/qt_source/’
I tried

p = QProcess()

But, it did not work. Could you help me for this problem?

Thank you.

I found a solution.
The problem semes to be from inconsistent use of setWorkingDirectory() and start().
After changing the code as follows, setWorkingDirectory() works.

p = QProcess()
1 Like

Thanks for posting the solution @Young-Ho_Song – I was out of the office over Christmas so missed this til now.

I wonder if this is related to the p.start('program') method now being deprecated?

If you look at the Qt documentation for start you’ll see you now must pass in the program name and the arguments as a separate list. For no arguments, you pass an empty list. I should make this clearer in the tutorial I think.

The method with only the program name – where you could pass the arguments in the same string – is deprecated.