PDA

View Full Version : QProcess



agent007se
22nd July 2006, 22:38
Hi all !

I'm trying to launch a program (any... if only one function that will be nice :p)



QProcess myprocess;
myprocess.startDetached("cmd.exe");
myprocess.waitForStarted(100000);
QMessageBox::information(0,"","");


With this code I have directly the message box but I never saw the cmd.exe prompt (win xp)... what's going wrong please :( (I'm looking for hours...)

Thanks !

edit:

I also tried this :


QString sbrowser = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";
QStringList qsl;
QProcess pbrowser;
qsl.push_back("http://www.google.com");
int tmp = pbrowser.startDetached(sbrowser, qsl);


(of course it didn't work...)

jacek
22nd July 2006, 23:26
myprocess.startDetached("cmd.exe");
QProcess::startDetached() is a static method --- you invoke it without an object instance:

QProcess::startDetached( "iexplore.exe", QStringList() << "http://www.google.com" );

agent007se
22nd July 2006, 23:37
True but that doesn't changed a lot of things but now I found this :

QProcess::FailedToStart == pbrowser.error()

with pbrowser.start(sbrowser, qsl); (instead of startDetached)

jacek
22nd July 2006, 23:38
Try:
QProcess::startDetached( "C:/Program Files/Internet Explorer/iexplore.exe", QStringList() << "http://www.google.com" );

agent007se
22nd July 2006, 23:40
valid instruction ! but don't work too :'(... that IS the problem...

of course, the file exists (QFile::exists return true) ;)

agent007se
22nd July 2006, 23:53
I tried this too :



QString sbrowser = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";
QProcess *pbrowser = new QProcess();
QStringList qsl;
qsl.push_back("http://www.google.com");
pbrowser->start(sbrowser, qsl);
if(QProcess::FailedToStart == pbrowser->error()) QMessageBox::information(0,"", "1");
else if(QProcess::Crashed == pbrowser->error()) QMessageBox::information(0,"", "2");
else if(QProcess::Timedout == pbrowser->error()) QMessageBox::information(0,"", "3");
else if(QProcess::WriteError == pbrowser->error()) QMessageBox::information(0,"", "4");
else if(QProcess::ReadError == pbrowser->error()) QMessageBox::information(0,"", "5");
else if(QProcess::UnknownError == pbrowser->error()) QMessageBox::information(0,"", "6");
QProcess::startDetached(sbrowser, qsl);


nothing at all (the message box shows 1 and the doc says:

The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.

it exists ... and I'm with the admin account (the only account in my computer)

jacek
22nd July 2006, 23:58
Does this work on your system?

#include <QCoreApplication>
#include <QProcess>

int main( int argc, char **argv )
{
QCoreApplication app( argc, argv );
QProcess::startDetached( "C:/Program Files/Internet Explorer/iexplore.exe", QStringList() << "http://www.google.com" );
return 0;
}

agent007se
23rd July 2006, 00:03
No and I just figured it out : KERIO (firewall) :eek:

Is there equivalent functions that aren't blocked by firewalls and antivirus ??

resolved : I cleared all my settings in kerio...

jacek
23rd July 2006, 00:21
Is there equivalent functions that aren't blocked by firewalls and antivirus ??
Won't such functions render them useless?

wysota
23rd July 2006, 00:30
Won't such functions render them useless?

No, because only GoodPeopleTM can use them.

agent007se
23rd July 2006, 01:11
No, because only GoodPeopleTM can use them.

Lol. Very funny ;). I just cleared my settings so it was my fault and now it works pretty well :D.