title: Using std::cout in Qt Gui
body: <p>I have an application that when run through terminal, the user has the option between command-line mode or GUI mode. </p>
  
  <p>There doesn't seem to be any output to the console at all when using <code>std::cout</code>. <code>std::cout</code> statements don't work in the main event loop. </p>
  
  <p>I have added <code>CONFIG += console</code> to my <code>.pro</code> file.</p>
  
  <p>For now, I have been using <code>QTextStream()</code> which works fine: </p>
  
  <p><code>QTextStream(cout) &lt;&lt; "Hello World" &lt;&lt; std::endl;</code></p>
  
  <p>My question is:</p>
  
  <p>Why can I not use <code>std::cout</code>? Does this have something to do with <code>Qt</code> affecting input and output streams? I couldn't find any documentation in Qt's docs on this. </p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      std::cout &lt;&lt; argv[1] &lt;&lt; std::endl;  //This is being outputted.
  
      //if(argc == 2 &amp;&amp; !strcmp(argv[1],"-win")){
      if(true){ //Just for this example's sake
      QApplication a(argc, argv);
  
      std::cout &lt;&lt; "Hello" &lt;&lt; std::endl;   //This is not being ouputted. 
      MainWindow w;
      w.show();
      return a.exec();
      }
      else
      {
          qDebug()  &lt;&lt; "Console Mode.\n";
          std::cout &lt;&lt; "Console Mode.\n";
  
          //Do stuff
      }
  
  
  }
  </code></pre>