Details
-
Suggestion
-
Resolution: Fixed
-
Not Evaluated
-
Qt Creator 13.0.2
-
None
-
-
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