Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-31212

qtcreator "new QCoreApplication" generated main.cpp

    XMLWordPrintable

Details

    • Linux/Wayland
    • 62d11c46a (14.0)

    Description

      When I use qtcreator with "New Project" for a "Qt Console Application", it creates a "main.cpp" file for me. The last line of this template has "return a.exec()" to run the Qt dispatch loop. When I run the application, it works and outputs the information I want. However, it never returns to the command prompt. I.e. the "a.exec()" never ends. If I run in qtcreator (cntl-r), I can close the terminal but need to "force quit" the application. If run from a normal bash prompt, it just "hangs" and I need to cntl-c to kill it. 

      I was able to "fix" this problem either by not doing "return a.exec()'" with "return 0;" However apparently this can disable some functionality, such as QTimer, which I might want. The solution, for me, to this is add one line before that "return a.exec()"

      QTimer::singleShot(1, &a, [] { exit(0); });

      I feel that I'm just foolishly overlooking something

       

      Attachments

        1. qtdiag6-output.txt
          11 kB
          John McKown
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            con Eike Ziller
            johnarchiemckown John McKown
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes