How to run a system command in Qt?

defiant picture defiant · Jul 12, 2010 · Viewed 65.1k times · Source

I have to run a system command in Qt. but I have to give an argument for that command.

for example opening gedit with a text file. like "gedit /home/oDx/Documents/a.txt"

but the path "/home/oDx/Documents/a.txt" will be in a variable like "docPath". so how can i do it!?

Answer

mosg picture mosg · Jul 12, 2010
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.