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. Application Output not displaying cout statements

Application Output not displaying cout statements

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 3.3k 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.
  • regnar86R Offline
    regnar86R Offline
    regnar86
    wrote on last edited by
    #1

    I'm about as new to Qt as you can get and I have a question in regards to displaying simple output. I normally use Xcode on my macbook for c++ development but since I'm about to start using Qt at work I thought it would be best to familiarize myself to Qt.

    Therefore, my question is how do I setup my Application Output window in Qt to display output for helping me debug my c++ source code. For example when I click build and then click run it displays my output in the "terminal" window. This is fine but its messy and I have to close out of my terminal session every time I run my program. Any help is appreciated.

    I'm sure we all know what a helloworld.cpp file looks like but for completeness here is my code below.

    #include <iostream>
    using namespace std;
    int main()
    {
    cout << "Hello World\n";
    return 0;
    }
    
    D 1 Reply Last reply
    0
    • regnar86R Offline
      regnar86R Offline
      regnar86
      wrote on last edited by regnar86
      #2

      So it appears when I'm in "Debug" mode I can see the output just fine in the "Application Output". However, when i'm in "Run" mode it doesn't output my cout statement in the "Application Output" but will in "Terminal". Which I guess is ok but would rather have more control over this feature.

      If i'm forced to use Terminal I would much rather use iTerm 2. Does someone have some advice here on how to control these features. I see I can add a path to the executable for iTerm2 in Preferences>Environment which I did as shown here.

      link text

      However, when I run my program it will display iterm 2 for like 1 second along with a weird error and vanishes.

      link text

      1 Reply Last reply
      0
      • jsulmJ Online
        jsulmJ Online
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        If you want to have some debug output then use qDebug() << "message";

        #include <QDebug>
        int main()
        {
        qDebug() << "Hello World";
        return 0;
        }
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • regnar86R regnar86

          I'm about as new to Qt as you can get and I have a question in regards to displaying simple output. I normally use Xcode on my macbook for c++ development but since I'm about to start using Qt at work I thought it would be best to familiarize myself to Qt.

          Therefore, my question is how do I setup my Application Output window in Qt to display output for helping me debug my c++ source code. For example when I click build and then click run it displays my output in the "terminal" window. This is fine but its messy and I have to close out of my terminal session every time I run my program. Any help is appreciated.

          I'm sure we all know what a helloworld.cpp file looks like but for completeness here is my code below.

          #include <iostream>
          using namespace std;
          int main()
          {
          cout << "Hello World\n";
          return 0;
          }
          
          D Offline
          D Offline
          Devopia53
          wrote on last edited by
          #4

          @regnar86

          Hi,

          Something like this:

          cout << "Hello World" << endl;
          

          std::endl flushes the output buffer but newline('\n').

          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