Search code examples
c++linuxqtsailfish-os

It is possible to run cmd's commands using C++ in QT app?


I am making a QT mobile app (Sailfish Os, it's made with Linux) and I need to run some processes with commands which could be run only with command line/terminal. Can I do this using QT/C++ code or I am talking about something impossible? :)


Solution

  • Yes it's possible, you can run Linux commands in Qt app by using QProcess. This is a small example:

    QProcess *system_command = new QProcess();
    system_command->start("/bin/bash");
    system_command->waitForFinished(500);
    system_command->write("ls -a\n");