Console window not displaying
-
wrote on 16 Mar 2022, 21:38 last edited by
Hello,
I just migrated from Qt 5.11.2 with MinGW 5.7.1 32 bit to Qt 6.2.3 MinGW 9.0.0 64 bit on Windows 10. I created the simplest possible project: A console application that just 'printf("Test"). The program compiles and runs, but the console window never displays. I created an empty, default widget application. It compiles, runs and displays the mainwindow. Any suggestions? -
wrote on 16 Mar 2022, 22:27 last edited by hskoglund
Hi, you're talking about running a console program from inside Qt Creator, right?
This behavior is not a bug, it's a feature in Qt Creator version 6. (Haven't tested Qt Creator version 7 yet but I expect the same as in version 6).In earlier versions of Qt Creator, for example 5.0.1, a console window appears as you mention. But in version 6 Qt Creator instead tries to route your printf() calls to the Application Output window in Qt Creator (so that your printf() calls behave more or less like calls to qDebug())
However this routing to the Application Output window usually never shows up due to the exec() call at the end of main().
I.e. before version 6 of Qt Creator you could use a simple console program like this:#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Test"); return a.exec(); }
but now you have to remove the exec() call:
#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Hello Qt Creator 6"); // return a.exec(); }
for the printf() call to show up in the Application Output window.
Edit: Good news! I jusr saw that you can revert to the old behavior (displaying a console window) via an option in the Build & Run, General tab. Look close to the bottom for the "Default for "Run in Terminal" and change it to "Enabled", voila :-)
-
Hi, you're talking about running a console program from inside Qt Creator, right?
This behavior is not a bug, it's a feature in Qt Creator version 6. (Haven't tested Qt Creator version 7 yet but I expect the same as in version 6).In earlier versions of Qt Creator, for example 5.0.1, a console window appears as you mention. But in version 6 Qt Creator instead tries to route your printf() calls to the Application Output window in Qt Creator (so that your printf() calls behave more or less like calls to qDebug())
However this routing to the Application Output window usually never shows up due to the exec() call at the end of main().
I.e. before version 6 of Qt Creator you could use a simple console program like this:#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Test"); return a.exec(); }
but now you have to remove the exec() call:
#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Hello Qt Creator 6"); // return a.exec(); }
for the printf() call to show up in the Application Output window.
Edit: Good news! I jusr saw that you can revert to the old behavior (displaying a console window) via an option in the Build & Run, General tab. Look close to the bottom for the "Default for "Run in Terminal" and change it to "Enabled", voila :-)
wrote on 16 Mar 2022, 23:53 last edited by@hskoglund said in Console window not displaying:
Edit: Good news! I jusr saw that you can revert to the old behavior (displaying a console window) via an option in the Build & Run, General tab. Look close to the bottom for the "Default for "Run in Terminal" and change it to "Enabled", voila :-)
Yes! It works, what a pleasure to see this good ol' black window again! Merci beaucoup !
Jean-Claude -
Hi, you're talking about running a console program from inside Qt Creator, right?
This behavior is not a bug, it's a feature in Qt Creator version 6. (Haven't tested Qt Creator version 7 yet but I expect the same as in version 6).In earlier versions of Qt Creator, for example 5.0.1, a console window appears as you mention. But in version 6 Qt Creator instead tries to route your printf() calls to the Application Output window in Qt Creator (so that your printf() calls behave more or less like calls to qDebug())
However this routing to the Application Output window usually never shows up due to the exec() call at the end of main().
I.e. before version 6 of Qt Creator you could use a simple console program like this:#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Test"); return a.exec(); }
but now you have to remove the exec() call:
#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Hello Qt Creator 6"); // return a.exec(); }
for the printf() call to show up in the Application Output window.
Edit: Good news! I jusr saw that you can revert to the old behavior (displaying a console window) via an option in the Build & Run, General tab. Look close to the bottom for the "Default for "Run in Terminal" and change it to "Enabled", voila :-)
wrote on 15 Sept 2022, 10:33 last edited by@hskoglund thank you for the answer! It helped me much!
-
wrote on 5 May 2023, 21:56 last edited by
-
You need to make the "Projects" tab active , then choose "Build & Run". In the "Run Settings" section you will find the checkbox to enable "Run in terminal". This is for Qt Creator version 10.0.0.
wrote on 8 Jun 2023, 17:34 last edited by@Don-Kemlage This method works, but is there no better way?
-
@Don-Kemlage This method works, but is there no better way?
@Elliot_foo said in Console window not displaying:
@Don-Kemlage This method works, but is there no better way?
There are other ways:
- Use
qDebug()
instead ofprintf()
, OR - Call
fflush(stdout);
after printf()
- Use
-
Hi, you're talking about running a console program from inside Qt Creator, right?
This behavior is not a bug, it's a feature in Qt Creator version 6. (Haven't tested Qt Creator version 7 yet but I expect the same as in version 6).In earlier versions of Qt Creator, for example 5.0.1, a console window appears as you mention. But in version 6 Qt Creator instead tries to route your printf() calls to the Application Output window in Qt Creator (so that your printf() calls behave more or less like calls to qDebug())
However this routing to the Application Output window usually never shows up due to the exec() call at the end of main().
I.e. before version 6 of Qt Creator you could use a simple console program like this:#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Test"); return a.exec(); }
but now you have to remove the exec() call:
#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Hello Qt Creator 6"); // return a.exec(); }
for the printf() call to show up in the Application Output window.
Edit: Good news! I jusr saw that you can revert to the old behavior (displaying a console window) via an option in the Build & Run, General tab. Look close to the bottom for the "Default for "Run in Terminal" and change it to "Enabled", voila :-)
wrote on 30 Apr 2024, 03:24 last edited by@hskoglund Oh man I need that, thank you!
-
Hi, you're talking about running a console program from inside Qt Creator, right?
This behavior is not a bug, it's a feature in Qt Creator version 6. (Haven't tested Qt Creator version 7 yet but I expect the same as in version 6).In earlier versions of Qt Creator, for example 5.0.1, a console window appears as you mention. But in version 6 Qt Creator instead tries to route your printf() calls to the Application Output window in Qt Creator (so that your printf() calls behave more or less like calls to qDebug())
However this routing to the Application Output window usually never shows up due to the exec() call at the end of main().
I.e. before version 6 of Qt Creator you could use a simple console program like this:#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Test"); return a.exec(); }
but now you have to remove the exec() call:
#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); printf("Hello Qt Creator 6"); // return a.exec(); }
for the printf() call to show up in the Application Output window.
Edit: Good news! I jusr saw that you can revert to the old behavior (displaying a console window) via an option in the Build & Run, General tab. Look close to the bottom for the "Default for "Run in Terminal" and change it to "Enabled", voila :-)
wrote on 14 Jun 2024, 18:53 last edited by@hskoglund thank you
-
wrote on 30 Jul 2024, 06:13 last edited by
-
Hello,
I follow your suggestion but it does not work, the consolle window does not appears. Instead it works in the terminal in bottom of QT creatorI use Qt creator 14 and QT 6.7.2
Please if someone kow the answer.wrote on 31 Jul 2024, 21:21 last edited by@marcolino I noticed in your first picture that the "Run in terminal" option is unchecked. Did you check this box, and apply the change?
-
Hello,
I follow your suggestion but it does not work, the consolle window does not appears. Instead it works in the terminal in bottom of QT creatorI use Qt creator 14 and QT 6.7.2
Please if someone kow the answer.@marcolino said in Console window not displaying:
Instead it works in the terminal in bottom of QT
That IS the embedded console