QProcess -> link output of 3rd party app back to my app
Hi,
at the moment i am using the following construction to launch a 3rd party app from my QT-based UI (developed on and for windows).
The cmd construction looks like this:
Code:
QProcess::startDetached("C2oooProgConsole.exe -s -d="+selectedDspType
+" -p="+ selectedInterface
+" -h="+ windowsFileName
+" -c");
So basically the 3rd party app is a commandline based application with some custom parms, which are defined in my UI.
Unfortunaly this output does launch itself in a DOS-Commandbox (cmd.exe) and closes itself after finishing. So i cant even read the output, as the window is already closed again.
As i cant find a parameter for this 3rd party app to let it pause after having finished i was thinking about linking the output directly into my app bck again, so that every single line which happens on the cmd-window is returned to my application UI. In best case i would just link it back to a QTextEdit which i am using right now as log-text-field.
That is the theoretical description....but is that somehow possible ? and if yes what should i search for in the AT doc's ? any suggestion / ideas ?
Best regards
ape
Re: QProcess -> link output of 3rd party app back to my app
Try
Code:
cmd.exe /k <command> <params..>
Oh, and I believe you should use a QStringList for the arguments, see QProcess::startDetached() docs.
Re: QProcess -> link output of 3rd party app back to my app
Hi jpn,
my basic construction works but yeah i have realized the QStringList point yesterday already.
Was just wondering if i really need to change my construction...as it was working ok already.
Regarding the pausing option:
your cmd.exe /k idea works great.
Guess i have to add a case-selection for old -windows systems where cmd was called command....but that should be easy right now.
Like always: big thanks to you JPN...you are a big help.
Best regards
ape
Re: QProcess -> link output of 3rd party app back to my app
Just realized that this construction does have a major problem.
QProcess construction:
Code:
QProcess::startDetached("cmd.exe /k C2oooProgConsole.exe -s -d="+selectedDspType
+" -p="+ selectedInterface
+" -h="+ windowsFileName
+" -c");
Problem:
If the variable "windowsFileName" does contains Spaces my QProcess construction does not work.
small example:
a) windowsFileName
C:\testfolder\subfolder\myfile.xy
does work
b) if windowsFileName =
C:\test folder\subfolder\myfile.xy
does NOT work and ends up ion the following error in cmd.exe:
File not found: C:\test
I guess thats the issue cause cmd just cuts the command/path of my file at the moment it reaches the Space. So am i correct, that i need to change my QProcess-construction or better the windowsfileName section to be sure that spaces does not matter anymore ?
But how would i do that ?
Usualy you would just add "" around the path but what is the solution in the contruction above ?
The only theoretical idea i have right now is adding " infront and behind the variable before evne using it. i.e. using prepend and append, but that does not work and i am not sure what is the best method to modify strings AND if this idea is solved better with another method
Re: QProcess -> link output of 3rd party app back to my app
You should pass all the arguments in a QStringList.
Re: QProcess -> link output of 3rd party app back to my app
Hi jpn,
ok i guess this time i really should follow your hint.
I got it working in the meantime using this construction:
Code:
windowsFileName.prepend('"');
windowsFileName.append('"');
but thats pretty dirty style.
Gonna test this a bit more and then try to implement your idea.
Like always: big thanks for your fast & good help.
Re: QProcess -> link output of 3rd party app back to my app
In fact, it would have been enough to actually read QProcess::startDetached() docs:
Quote:
On Windows, arguments that contain spaces are wrapped in quotes.
Code:
arguments << "/k" << "C2oooProgConsole.exe" << "-s" << ...;
QProcess::startDetached("cmd.exe", arguments
);
Re: QProcess -> link output of 3rd party app back to my app
it is popup output along with cmd prompt. how to disappear that cmd prompt