title: redirect std::cout to QTextEdit
body: <p>Is it possible (and more importantly -how-) to redirect an output stream to a QTextBox. So that if I write <code>std::cout &lt;&lt; "test"</code> anywhere in the application it gets redirected to a textbox I defined?</p>
  
  <p>I tried the obvious (where ui.textEdit is a pointer to the text edit box): </p>
  
  <pre><code>std::cout.rdbuf(ui.textEdit);
  std::cout &lt;&lt; "test";
  </code></pre>
  
  <p>However this doesn't work. (obviously). - Nor does redirecting cout to qDebug work (or even direction a qDebug to a textfield).</p>
  
  <p>I'm using qt4.8 btw...</p>
  
  <p>EDIT:
  So I tried the solution posted in the mailing list.. However now an access violation shows up.</p>
  
  <pre><code>class MainInterface : public QMainWindow
  {
      Q_OBJECT
  ....
  private: 
      QDebugStream qout
  </code></pre>
  
  <p>With the constructor:</p>
  
  <pre><code>MainInterface::MainInterface(QWidget *parent, Qt::WFlags flags)
      : QMainWindow(parent, flags),
      qout(std::cout, ui.textEdit)
  {
  </code></pre>
  
  <p>And in a member function the following line is posted:  <code>std::cout &lt;&lt; "Project Loaded" &lt;&lt; std::endl;</code></p>
  
  <p>That line now causes an access violation from "qscoped_pointer". (Should I post this with more detail as seperate question?)</p>
  
  <p>EDIT: well the "solution" was to only declare qout after the ui.textEdit was fully created.</p>