PDA

View Full Version : QProcess with different versions of Qt



mclark
28th December 2007, 00:40
My GUI app is running Qt 4.2.2 and as a last minute addition, the marketing dept wants a new feature. They want my program to start another program. Ordinarily this would not be a problem, but...

In the QMainWindow constructor I want to start the other Qt GUI program. This other program is using a newer (unknown) version of Qt. I think this may be the problem.

I try to invoke the program (which never starts) by:

QString sFullPath( "C:\\Program Files\\Net3Helper\\Net3Helper.exe" );
if ( !QProcess::startDetached( sFullPath ) )
qDebug( "%s not started!", sFullPath.toAscii().data() );
If I change my file path string to...

QString sFullPath( "C:\\WINDOWS\\System32\\calc.exe" );
...the Windows calculator program starts as expected.

I am working in MS Visual Studio 2005. The other apps directory contains the Qt DLLs required for its operation. Could it be that the 4.2.2 DLLs loaded for the main application are interfering with the ones in the Net3Helper directory?

If so, is there a solution to this problem other than having both applications use the same version of Qt? This is not possible as the program must be done within the next 2 weeks!

marcel
28th December 2007, 00:52
Weird...
What happens if you create a batch file for starting the second program, and execute the batch file with QProcess? The usual way is to pass the batch file as parameter to cmd.exe.

EDIT: perhaps there's a problem with spaces in the path. Can you try with:


QString sFullPath( "C:\\Progra~1\\Net3Helper\\Net3Helper.exe" );
?

mclark
28th December 2007, 01:33
The problem is Windows (and a programmer with a short memory), isn't that most always the case? Since the full path contained a space in it, there needed to be quotes around it before the system would understand it.

Not:

QString sFullPath( "C:\\Program Files\\Net3Helper\\Net3Helper.exe" );
QProcess::startDetached( sFullPath );
but,

QString sFullPath( "\"C:\\Program Files\\Net3Helper\\Net3Helper.exe\"" );
QProcess::startDetached( sFullPath );
Thanks for looking at this Marcel!