0

I have 2 programs:

program 1 - A Qt program written by me.

program 2 - A program not written by.

My goal is to run program 2 from program 1 ( I know how to do that).

My problem, however, is that program 2 has some .ini files which it looks for. It turns out that the directory program 2 looks in is not the directory of the executable, but rather the directory of the process starting the executable...in this case program 1.

so my error reads something like this:

"could not find file xxx.ini in directory C://directory of program 1//inifiles//...

my question is...is there any way I can go around this? I know it's a little confusing, so please tell me if something doesn't make sense.

2 Answers 2

4

Assuming you are using QProcess to start program 2, you need to set the working directory by calling QProcess::setWorkingDirectory(const QString &dir).

The documentation states:

Sets the working directory to dir. QProcess will start the process in this directory. The default behavior is to start the process in the working directory of the calling process.

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

Comments

0

If you want to find out what directory you're currently using try something like:

QDir application_dir = QDir( QDir::currentPath() );

This is quite useful for debugging purposes.

Comments

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.