PDA

View Full Version : Possible to return to command prompt immediately?



Pembar
26th June 2009, 13:37
Hey guys,

Whenever I run my code, after executing the program from command prompt, the command prompt waits there until my program quits. Is there anyway to have it return back to command prompt immediately after launching the program?

Thanks.

Regards,
Pembar

drescherjm
26th June 2009, 14:12
This is a function of the command prompt / shell.

In windows start your program with

start

In *nix use a
&
on the end of the command line

Pembar
26th June 2009, 15:22
I'm trying to avoid using 'start'.

As an example, in windows, goto command prompt and type "qtdemo", or "assistant".

How did they do it? I tried going through the .pro file, nothing that stands out.

drescherjm
26th June 2009, 15:34
Interesting. Neither of them returned in 4nt but they do in cmd.exe.

shentian
26th June 2009, 18:56
When I start my own Qt GUI applications from cmd.exe, they also return immediately to the prompt.

A console application doesn't, though.

wysota
27th June 2009, 00:19
A console application grabs the terminal. Under Unix the proper thing to do is to either call fork() and kill the parent or call daemon(). In either case the application detaches itself from the terminal.

Pembar
29th June 2009, 12:43
We're using Microsoft Visual Studio and CMake to compile the program, so .pro files aren't used. Does anyone know where to change the settings and what to change it to so that it runs as a GUI application instead of a console application?

Thanks

drescherjm
29th June 2009, 18:38
/SUBSYSTEM:WINDOWS linker flag removes the console.

Here are two methods:

if(WIN32)
set_target_properties(WindowApplicationExample PROPERTIES
LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
set_target_properties(WindowApplicationExample PROPERTIES
RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
set_target_properties(WindowApplicationExample PROPERTIES
LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
set_target_properties(WindowApplicationExample PROPERTIES
MINSIZEREL "/SUBSYSTEM:WINDOWS")
endif(WIN32)


Or, you can do this: add_executable(myexe WIN32 myexe.cxx) See the documentation for add_executable.


There is more info on this if you google search for "How to hide the console for a VTK/Qt app"

Scorp2us
29th June 2009, 22:11
Use a QApplication, not a QCoreApplication. Your project type then has to be changed from CONSOLE to GUI. Then just don't make a window.