Important: Please read the Qt Code of Conduct -

Catching QProcess ExitStatus - how ?

  • I am quite new to Qt5 and C++, and I am making a basic app launcher for desktop Windows/Linux.

    I got very basic functionality done yesterday, namely Start button starts .exe file, and Quit button quits launcher.

    Now I need to go a bit further and do the following. I need to check for process, and if it's still running, pressing Quit button would pop a new window saying "Your app is still running, please shut it down first" and Ok button, pressing which goes back to launcher's main window.

    Then I need to have a check for process exit status, and if it shuts down normally, quit launcher automatically.

    How do I do that? (I used QtDesigner to make UI, so the code in mainwindow.cpp is quite short, if it's relevant)


  • Moderators

    Whenever processs finishes QProcess emits a signal "finished()": It indicates the exit status and app exit code.

    You can also check if the process is still running with "state()":

Log in to reply