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

Run a terminal command with a button click



  • Hi,
    We are creating a GUI for our Rover project. Rover is working with ROS and right now we are dealing with a problem.
    We are using different programs for the vehicle, one of them is Rviz. We have a 3D model on Rviz and we open that model with terminal codes:

    1. We open the terminal
    2. We start the roscore with "roscore".
    3. We open another terminal and go to the direction that launch file exists
    4. and launch the model with "roslaunch display.launch" (display.launch is the file name)

    That opens the full model on Rviz. We want to make it happen with single button click but all solutions are useless. QProcess is not working, the program never opens and says as output "QProcess: Destroyed while process ("...") is still running.".

    So the question is, how can we start a terminal and run a terminal command? Terminal doesn't have to appear, only the code should work (if terminal appears, it is not a problem).

    NOTE: roslaunch or roscore is not system commands, other system commands work but these are not working.



  • @aliemrenebiler said in Run a terminal command with a button click:

    QProcess is not working, the program never opens and says as output "QProcess: Destroyed while process ("...") is still running.".

    The problem would appear to be that your QProcess object goes out of scope (is destroyed) while the process you asked it to launch is still running i.e. exactly what the error message says. This is most likely because you have create the QProcess on the stack in the slot handling your button click, but it could be because it is parented to another QObject that is destroyed.

    We can only guess without seeing your code.