Results 1 to 9 of 9

Thread: how to make command prompt wait till the execution of exe.

  1. #1
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Wink how to make command prompt wait till the execution of exe.

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: how to make command prompt wait till the execution of exe.

    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:

    Qt Code:
    1. #include <QApplication>
    2. #include <QLabel>
    3.  
    4. int main( int argc, char **argv )
    5. {
    6. QApplication app( argc, argv );
    7. (new QLabel("My advanced GUI application"))->show();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    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?

  3. #3
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: how to make command prompt wait till the execution of exe.

    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

  4. #4
    Join Date
    Aug 2009
    Posts
    47
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded PyQt3 PyQt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: how to make command prompt wait till the execution of exe.

    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

  5. #5
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: how to make command prompt wait till the execution of exe.

    Quote Originally Posted by kavinsiva View Post
    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]...

  6. #6
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: how to make command prompt wait till the execution of exe.

    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 ?!

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to make command prompt wait till the execution of exe.

    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.

  8. #8
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: how to make command prompt wait till the execution of exe.

    Quote Originally Posted by drhex View Post
    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.

  9. #9
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: how to make command prompt wait till the execution of exe.

    Quote Originally Posted by fatjuicymole View Post
    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.

Similar Threads

  1. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57
  2. How to make my program wait for 2 seconds ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 26th December 2006, 13:31
  3. how to make program wait
    By psmech in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 05:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.