I want to execute an .exe file, which was compiled by g++ (or gcc) from a Qt program. I refer to this topic and try to make it run:
// Setup the working directory
QDir::setCurrent("/home/myproject");
// Start the process (uses new working dir)
bool t= myProc.startDetached("./work");
if (t==false) std::cout<< "Error";
else std::cout <<"OK";
but the result I have is always "Error" and there is no change in my screen even if the program "work" is a GUI program. I did it in terminal but in QProcess I can't :(. What am I doing wrong?
.exeto your executable?./work. The current directory looks broken, it should be an absolute path also, e.g./home/youruser. Also note that startDetached is a static method and does nothing tomyProc,QProcess::startDetached(…)would be the usual syntax (but yours should work, too)