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

Console window not displaying

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 10 Posters 5.4k Views
  • 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 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
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on 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 ImElijahI 4 Replies Last reply
      3
      • hskoglundH 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 :-)

        J Offline
        J Offline
        jcga
        wrote on 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
        • hskoglundH 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 :-)

          M Offline
          M Offline
          MIKELANGELO
          wrote on 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 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
            2
            • D Don Kemlage

              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 last edited by
              #6

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

              JKSHJ 1 Reply Last reply
              0
              • E Elliot_foo

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

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on 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
                • hskoglundH 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 :-)

                  M Offline
                  M Offline
                  MrJoeHimself
                  wrote on last edited by
                  #8

                  @hskoglund Oh man I need that, thank you!

                  1 Reply Last reply
                  0
                  • hskoglundH 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 :-)

                    ImElijahI Offline
                    ImElijahI Offline
                    ImElijah
                    wrote on last edited by
                    #9

                    @hskoglund thank you

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      marcolino
                      wrote on 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
                      0
                      • M marcolino

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

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