Alex Rivera | Logout

How to run a system command using Qt?

Asked 2010-07-12T10:45:37.883
68

I need to execute a system command in Qt and provide an argument for the command.

For example, opening a text file with gedit:

gedit /home/oDx/Documents/a.txt

But the path /home/oDx/Documents/a.txt will be in a variable like docPath.

How can I achieve this?

Edit
Report

1 Answer

95
QProcess process;
process.start("gedit", QStringList() << docPath);

the same as above

QProcess process;
process.start("gedit", QStringList() << "/home/oDx/Documents/a.txt");

Also, read this.

answered 2010-07-12T10:57:34.210

Your Answer