Skip to content

Instantly share code, notes, and snippets.

Last active February 3, 2022 16:24
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Sample qt program to execute Linux commands
//Author : Anil C S
//Website :
#include <iostream>
#include <QProcess>
using namespace std;
int main(int argc, char *argv[])
cout<<"\n * Program to demonstrate the usage of linux commands in qt * \n";
QProcess OProcess;
QString Command; //Contains the command to be executed
QStringList args; //Contains arguments of the command
Command = "ls";
OProcess.start(Command,args,QIODevice::ReadOnly); //Starts execution of command
OProcess.waitForFinished(); //Waits for execution to complete
QString StdOut = OProcess.readAllStandardOutput(); //Reads standard output
QString StdError = OProcess.readAllStandardError(); //Reads standard error
cout<<"\n Printing the standard output..........\n";
cout<<"\n Printing the standard error..........\n";
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment