Qt - QProcess not working

I am trying to start Internet Explorer, so I am using the code below

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

But that will not work.

+3
source share
2 answers

Try:

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

You need to use escaped quotes, as the path has a space in it, or possibly leaves all spaces (you missed Program\ Filesin the code you posted).

+6
source

How about this?

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

Source: https://habr.com/ru/post/1774967/


All Articles