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. Console window not displaying
Forum Updated to NodeBB v4.3 + New Features

Console window not displaying

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 10 Posters 5.5k Views 3 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.
  • J Offline
    J Offline
    jcga
    wrote on 16 Mar 2022, 21:38 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hskoglund
      wrote on 16 Mar 2022, 22:27 last edited by hskoglund
      #2

      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 :-)

      J M M I 4 Replies Last reply 16 Mar 2022, 23:53
      3
      • H hskoglund
        16 Mar 2022, 22:27

        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 :-)

        J Offline
        J Offline
        jcga
        wrote on 16 Mar 2022, 23:53 last edited by
        #3

        @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

        1 Reply Last reply
        0
        • H hskoglund
          16 Mar 2022, 22:27

          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 :-)

          M Offline
          M Offline
          MIKELANGELO
          wrote on 15 Sept 2022, 10:33 last edited by
          #4

          @hskoglund thank you for the answer! It helped me much!

          1 Reply Last reply
          1
          • D Offline
            D Offline
            Don Kemlage
            wrote on 5 May 2023, 21:56 last edited by
            #5

            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.

            EnableTerminalWindowForConsoleApp.png

            E 1 Reply Last reply 8 Jun 2023, 17:34
            2
            • D Don Kemlage
              5 May 2023, 21:56

              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.

              EnableTerminalWindowForConsoleApp.png

              E Offline
              E Offline
              Elliot_foo
              wrote on 8 Jun 2023, 17:34 last edited by
              #6

              @Don-Kemlage This method works, but is there no better way?

              JKSHJ 1 Reply Last reply 9 Jun 2023, 05:26
              0
              • E Elliot_foo
                8 Jun 2023, 17:34

                @Don-Kemlage This method works, but is there no better way?

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on 9 Jun 2023, 05:26 last edited by
                #7

                @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 of printf(), OR
                • Call fflush(stdout); after printf()

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

                1 Reply Last reply
                2
                • H hskoglund
                  16 Mar 2022, 22:27

                  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 :-)

                  M Offline
                  M Offline
                  MrJoeHimself
                  wrote on 30 Apr 2024, 03:24 last edited by
                  #8

                  @hskoglund Oh man I need that, thank you!

                  1 Reply Last reply
                  0
                  • H hskoglund
                    16 Mar 2022, 22:27

                    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 :-)

                    I Offline
                    I Offline
                    ImElijah
                    wrote on 14 Jun 2024, 18:53 last edited by
                    #9

                    @hskoglund thank you

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      marcolino
                      wrote on 30 Jul 2024, 06:13 last edited by
                      #10

                      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 creatordaCancellare.JPG daCancellare2.JPG

                      I use Qt creator 14 and QT 6.7.2
                      Please if someone kow the answer.

                      mzimmersM JKSHJ 2 Replies Last reply 31 Jul 2024, 21:21
                      0
                      • M marcolino
                        30 Jul 2024, 06:13

                        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 creatordaCancellare.JPG daCancellare2.JPG

                        I use Qt creator 14 and QT 6.7.2
                        Please if someone kow the answer.

                        mzimmersM Offline
                        mzimmersM Offline
                        mzimmers
                        wrote on 31 Jul 2024, 21:21 last edited by
                        #11

                        @marcolino I noticed in your first picture that the "Run in terminal" option is unchecked. Did you check this box, and apply the change?

                        1 Reply Last reply
                        0
                        • M marcolino
                          30 Jul 2024, 06:13

                          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 creatordaCancellare.JPG daCancellare2.JPG

                          I use Qt creator 14 and QT 6.7.2
                          Please if someone kow the answer.

                          JKSHJ Offline
                          JKSHJ Offline
                          JKSH
                          Moderators
                          wrote on 13 Aug 2024, 07:14 last edited by
                          #12

                          @marcolino said in Console window not displaying:

                          Instead it works in the terminal in bottom of QT

                          That IS the embedded console

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

                          1 Reply Last reply
                          0

                          • Login

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