I have a exe folder located in one folder, and then all of my config files in another. In order to run the program:
- I need to direct the terminal to the config file folder
- Then run the exe folder, with arguments.
Shown below, I have this working correctly using system calls, but I need a system agnostic way of doing this.
void MainWindow::on_pushButton_clicked()
{
std::system("cd Path_To_ConfigFolder & Absolute_Path_To_Exe RunFile.txt > logfile.txt");
}
The above works great. Although it only works on Windows.. so I did some research on using QProcess to create a more system agnostic way.. and no matter what I try I can't seem to get this to work. See below:
void MainWindow::on_pushButton_clicked()
{
QProcess p;
QStringList params;
p.setWorkingDirectory("Path_To_ConfigFolder");
params << " RunFile.txt > logfile.txt";
p.start("Absolute_Path_To_Exe", params);
p.waitForFinished(-1);
}
Note: For the above example (using QProcess), I am \\
for all my paths, and all my paths are correct.
What am I doing wrong here?