I'm trying to execute a process in Qt (in Linux) that executes a python script and I haven't been able to make it work. This is the code:
QProcess process;
QString scriptFile = "../../scriptPath/script.py";
QString pyCommand = "\"python " + scriptFile +
" -f " + parameter1 +
" -t parameter2" +
" -v parameter3" +
" -e " + parameter4 + "\"";
printf("PyCommand: %s\n", qStringToStdString(pyCommand).c_str());
process.start ("bash", QStringList () << "-c" << pyCommand);
Where parameter1
and parameter3
are QStrings that I get from file dialogs (both paths are correct) and parameter2
and parameter4
are hardcoded strings (just in case, these strings have characters "-" and "." in them). Function qStringToStdString
is a function I have created to transform a QString
to a std::string
and it works just fine (I already have used it).
PyCommand is printed in the console and looks fine. In fact, if I open a terminal and try to execute bash -c
followed by what I get in the printf instruction it works. But it doesn't work when I execute the Qt application.
Can someone help me out here? Something I'm missing?