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
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("QDIR", "C:\\Qt\\2010.01\\qt"); // Add an environment variable
env.insert("PATH", env.value("Path") + ";C:\\Qt\\2010.01\\qt\\bin");
env.insert("QMAKESPEC", "win32-g++"); // Add an environment variable
firstProcess->setProcessEnvironment(env);
arguments << m_pathToProjectFiles + "/MyProject.pro" << "CONFIG+=release";
firstProcess->start(qmake, arguments);
firstProcess->waitForFinished();
QProcess *firstProcess = new QProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("QDIR", "C:\\Qt\\2010.01\\qt"); // Add an environment variable
env.insert("PATH", env.value("Path") + ";C:\\Qt\\2010.01\\qt\\bin");
env.insert("QMAKESPEC", "win32-g++"); // Add an environment variable
firstProcess->setProcessEnvironment(env);
QString qmake ="qmake.exe";
QStringList arguments;
arguments << m_pathToProjectFiles + "/MyProject.pro" << "CONFIG+=release";
firstProcess->start(qmake, arguments);
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!!
Bookmarks