Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to quit a console application normally?
Forum Updated to NodeBB v4.3 + New Features

How to quit a console application normally?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MozzieM Offline
    MozzieM Offline
    Mozzie
    wrote on last edited by
    #1

    So, there it is:
    I have write a console application, recently, I found every time when i close the console window, my application not return a zero exit code, but

    D:\Development\QtProject\build-untitled-Desktop_Qt_5_14_0_MSVC2017_64bit-Debug\debug\untitled.exe exited with code -1073741510
    

    I thought it was my program that went wrong. but after a lot of test I found even a simple project just create still have this problem.

    I found some doc says this is because of event loop, but i can not remove event loop, I need it.

    the first is can i capture key event in a console application?
    then what should I do to make my application return 0 when exit.

    Thank you.

    JKSHJ 1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      So where is the sourcecode for your simple console application? Folks cannot help if they cannot see what you tried.

      Also, console application means CONSOLE, not window. If you close the windoze CMD windows where the console application is running then it is going to abnormally terminate the program. If you don't want to get an error code then you must normally exit the console app BEFORE closing the window... or handle the termination signal from the shell...which could be haphazard in windoze.

      1 Reply Last reply
      3
      • MozzieM Mozzie

        So, there it is:
        I have write a console application, recently, I found every time when i close the console window, my application not return a zero exit code, but

        D:\Development\QtProject\build-untitled-Desktop_Qt_5_14_0_MSVC2017_64bit-Debug\debug\untitled.exe exited with code -1073741510
        

        I thought it was my program that went wrong. but after a lot of test I found even a simple project just create still have this problem.

        I found some doc says this is because of event loop, but i can not remove event loop, I need it.

        the first is can i capture key event in a console application?
        then what should I do to make my application return 0 when exit.

        Thank you.

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @Mozzie said in How to quit a console application normally?:

        what should I do to make my application return 0 when exit.

        You must make your application shut down properly by calling QCoreApplication::quit().

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved