PDA

View Full Version : Problem with QProcess when execute different kind of .exe files



wolfguolei
9th July 2012, 13:06
Hi there,

I have encountered a QProcess problem when I trying to call QProcess::start().There is my source code:


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

My project is simple,I just want to open another application(*.exe) after I clicked the button on my current ui.This project works well,but when I replace the iexplore.exe with other Qt compiled execute file,It would not work any more.
Like this one:


QProcess * process=new QProcess(this);
QString temp="\"E:\\QTProject\\openExe\\xmltest.exe\"";
process->startDetached(temp);

I supervise the process->state() and it printed "2" which means the process had been already running,but there is nothing happend,just like I didn't do a thing. And all *.exe file, including xmltest.exe , I have tested are all compiled by Qt.4.8.
Has anyone known it about?Please help.

high_flyer
9th July 2012, 13:12
Does E:\\QTProject\\openExe\\xmltest.exe\ runs when you double click it?

wolfguolei
9th July 2012, 13:40
yeah,sure it's running.And I have tested all Qt compiled execute files ,did not work.But other .exe files did.

high_flyer
9th July 2012, 13:44
yeah,sure it's running.
Nothing is sure and there is a good reason I asked.
My guess is that you have problem with your environment and that your exe can't find the Qt dlls when you start it in your QProcess.
Try this:
QProcessEnvironment

wolfguolei
9th July 2012, 13:52
Thanks for your tips man.
Can you tell me how to use it,or give me a example depend on this


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


thanks very much

high_flyer
9th July 2012, 13:54
Can you tell me how to use it
Not better than the docs can.

wolfguolei
9th July 2012, 14:20
Thank you all the same, though I still can't understand it...:crying:

high_flyer
9th July 2012, 14:22
If you be more specific about what it is you don't understand (best would be a description of what you have tried) maybe I can help you more.