PDA

View Full Version : how to make command prompt wait till the execution of exe.



nikhilqt
23rd October 2009, 16:45
Hi,

I am invoking QApplication eventloop(i.e., GUI). One of my requirement is also to support batch execution.

since one of my dependent library expects my application to be GUI, I need to use QApplication. Therefore am not using QCoreApplication.

My problem is if I try to execute my exe in command prompt with command line parameters the cmd prompt wont wait untill execution completes.

Is there any way where I can wait/hold the command prompt till the execution completes.

Hope my question is clear.

Thanks.

drhex
23rd October 2009, 22:19
Well, how do you start the program from the command prompt? Normally it is the shell that puts an application in the background rather than the GUI-parts of a Qt app.

Take this for example:


#include <QApplication>
#include <QLabel>

int main( int argc, char **argv )
{
QApplication app( argc, argv );
(new QLabel("My advanced GUI application"))->show();
return app.exec();
}

If I start that from a command prompt, there won't be a new prompt until I close the window. Does your app put itself in the backgound?

nikhilqt
26th October 2009, 12:04
Even though the application instance is QApplication, I maintain strictness of not displaying any GUI window in the console. So there is no any modal dialog/or any similar thing, as a result the command prompt appears immediately..

Please let me know if am not clear..

Thanks for the reply.
Nikhil

kavinsiva
26th October 2009, 12:29
while executing your exe file add a " & " at the end of line in unix,
it will set the your applications as Backend process and you may use your cmd prompt

bye

nikhilqt
26th October 2009, 13:38
while executing your exe file add a " & " at the end of line in unix,
it will set the your applications as Backend process and you may use your cmd prompt

bye

Thanks. I know about the backend process in UNIX. Am working in windows. that too, my request is user should feel that the exe is still processing[by not displaying prompt immediately]...

drhex
26th October 2009, 20:52
By the time you get the unwanted prompt back, is your program still running or do you merely want to give an impression that it is running ?!

squidge
26th October 2009, 21:24
by default on Windows, as soon as you start a gui application it will give you back the command prompt as soon as the program starts running.

Have a look at GetExitCodeProcess. If the process has not terminated and the function succeeds, the status returned is STILL_ACTIVE.

nikhilqt
27th October 2009, 10:05
By the time you get the unwanted prompt back, is your program still running or do you merely want to give an impression that it is running ?!

yes program is still running, not an impression. The prompt has to wait till the execution completes.

nikhilqt
27th October 2009, 10:07
by default on Windows, as soon as you start a gui application it will give you back the command prompt as soon as the program starts running.

Have a look at GetExitCodeProcess. If the process has not terminated and the function succeeds, the status returned is STILL_ACTIVE.

I believe i did not get what you are saying. The command prompt appearence depends on the subsystem what you set. If it is console then it comes, else it wont. I want my subsystem to be remain as windows.