Results 1 to 9 of 9

Thread: Possible to return to command prompt immediately?

  1. #1
    Join Date
    May 2009
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Possible to return to command prompt immediately?

    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

  2. #2
    Join Date
    Apr 2008
    Location
    Pittsburgh,PA,USA
    Posts
    48
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Possible to return to command prompt immediately?

    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
    John

  3. #3
    Join Date
    May 2009
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Possible to return to command prompt immediately?

    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.

  4. #4
    Join Date
    Apr 2008
    Location
    Pittsburgh,PA,USA
    Posts
    48
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Possible to return to command prompt immediately?

    Interesting. Neither of them returned in 4nt but they do in cmd.exe.
    John

  5. #5
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Possible to return to command prompt immediately?

    When I start my own Qt GUI applications from cmd.exe, they also return immediately to the prompt.

    A console application doesn't, though.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Possible to return to command prompt immediately?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2009
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Possible to return to command prompt immediately?

    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

  8. #8
    Join Date
    Apr 2008
    Location
    Pittsburgh,PA,USA
    Posts
    48
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Possible to return to command prompt immediately?

    /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"
    Last edited by drescherjm; 29th June 2009 at 17:44.
    John

  9. #9
    Join Date
    Apr 2008
    Posts
    45
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Possible to return to command prompt immediately?

    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.

Similar Threads

  1. error with QList with a class
    By john_god in forum Newbie
    Replies: 7
    Last Post: 12th January 2009, 21:48
  2. QTableView performances
    By miraks in forum Qt Programming
    Replies: 18
    Last Post: 1st December 2008, 10:25
  3. Once more : QAbstractItemModel woes
    By Valheru in forum Qt Programming
    Replies: 10
    Last Post: 15th January 2008, 10:44
  4. QTableView Repaint/Refresh
    By millsks in forum Newbie
    Replies: 9
    Last Post: 10th January 2008, 17:18
  5. Version 4.1.3 and QTreeView
    By greencastor in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 10:37

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.