开发者

How to run a system command in Qt?

开发者 https://www.devze.com 2023-01-07 10:35 出处:网络
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.

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. l开发者_Go百科ike "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!?


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.


QProcess::execute() may be helpful, although is deprecated:

QProcess::execute("gedit /home/oDx/Documents/a.txt");
0

精彩评论

暂无评论...
验证码 换一张
取 消