简体   繁体   English

Qt - QProcess无效

[英]Qt - QProcess is not working

I try to launch internet explorer, So I use the below code 我尝试启动Internet Explorer,所以我使用下面的代码

QProcess * process=new QProcess(this);
QString temp="C:\\Program Files\\Internet\ Explorer\\iexplore.exe";
process->startDetached(temp.toStdString().c_str());

But it doesn't work. 但它不起作用。

Try: 尝试:

QProcess * process=new QProcess(this);
QString temp="\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"";
process->startDetached(temp);

You need to use escaped quotes since the path has a space in it, or possibly escape all the spaces (you missed Program\\ Files in the code you posted). 您需要使用转义引号,因为路径中有空格,或者可能转义所有空格(您在所发布的代码中错过了Program\\ Files )。

How about that? 那个怎么样?

QDir dir("C:\\");
QProcess::execute("explorer.exe", QStringList() << dir.toNativeSeparators(dir.path()));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM