Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to run a project in QT C++ by another project?



  • Hi There,

    I have a project in Qt c++ (QT Widget application). I want to have a button in my project (App) that by pressing this button, another project in another directory ( a Console project) starts to run. Indeed, the directories of my projects differ from each other. I want to know, is it possible to run my console project by a widget project while these projects are not in the same directory? If yes, how?

    Thank you!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    To run external application you can use QProcess.



  • Thank you for your reply. Excuse me if I am asking a low level question. I am beginner in programming.
    I am not going to run another application. I am going to run an external console project by another project in different directories. Does Qprocess method work in this case?


  • Lifetime Qt Champion

    I understood that you wanted to run an application built from a different project. I may have misunderstood you.

    Can you explain the steps you are looking to implement ?



  • This is a summary of what I am going to do:

    I have some console projects that each one is developed for a particular task. I am working on a GUI to control all these projects (for example changing parameters in these projects and also control when to run each one). It is not possible for me to integrate all these projects in one directory (GUI's directory). Hence, I am forced to run these projects through their current directories, which differ from each other.


  • Lifetime Qt Champion

    So what's the problem to use QProcess as @SGaist already said?


  • Lifetime Qt Champion

    Hi
    QProcess allows running another .exe file anywhere on your drive.
    So yes, you can run the .exe produced by the
    "an external console project by another project"

        QString program = "c:/path/toyour.exe";
        QStringList arguments;
        // if needed:  arguments << "xxxx" << "yyyy";
        QProcess *myProcess = new QProcess(parent);
        myProcess->start(program, arguments);
    

    That will start the console as like you had clicked on it.


Log in to reply