Hi guys,

Im coding an app that will need to build other Qt projects. The user will select the project to build and my app have to build it and provide the executable.

I think that I can do it by using QProcess but I cannot get it.

Lets get some code
Qt Code:
  1. QProcess *firstProcess = new QProcess;
  2. QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  3. env.insert("QDIR", "C:\\Qt\\2010.01\\qt"); // Add an environment variable
  4. env.insert("PATH", env.value("Path") + ";C:\\Qt\\2010.01\\qt\\bin");
  5. env.insert("QMAKESPEC", "win32-g++"); // Add an environment variable
  6. firstProcess->setProcessEnvironment(env);
  7.  
  8. QString qmake ="qmake.exe";
  9. QStringList arguments;
  10. arguments << m_pathToProjectFiles + "/MyProject.pro" << "CONFIG+=release";
  11.  
  12. firstProcess->start(qmake, arguments);
  13. firstProcess->waitForFinished();
To copy to clipboard, switch view to plain text mode 

But it doesn create the Make file. I noticed that QT provides a Qt Command promp, that sets some environment variables. I tried to reproduce that by using the "env.insert" sententences in the code. But it doesnt work.

Another cool thing could be just execute the Qt command promp from the code (so the process programm could be C:\Windows\System32\cmd.exe /K C:\Qt\2010.01\bin\qtenv.bat )

But then, If I execute in the process the cmd, how can I inside that process execute some other programs (like qmake or make). Do I have to create a bat file and execute it from QProcess?

Thanks!!