Hello! Friends,
I have designed a GUI in which i have lots of cout & cerr messages. Right now am able to see all those in console window but i want them to be displayed in my GUI's QTextEdit widget.

For this i made forum search and found this from where i got to know that i will have to make my own streaming class that inherits std:stream and outputs everything using qDebug or some completely different mechanism. Also here i found that i can use qdebugstream.h header to do the needful, but its not working May be i might have made mistake in implementing it.

Here is what i tried: -
Qt Code:
  1. #include <QtGui>
  2. #include <iostream>
  3. #include "qdebugstream.h"
  4.  
  5. using namespace std;
  6.  
  7. #include "log.h"
  8.  
  9. mylog::mylog(QWidget *parent)
  10. :QWidget( parent )
  11. {
  12. setupUi(this); // this sets up GUI
  13. mylog::setWindowTitle(QString("Checking log"));
  14.  
  15. connect( Start, SIGNAL( clicked() ), this, SLOT( examine() ) );
  16. }
  17.  
  18. void mylog::examine()
  19. {
  20. cout <<"Hello! We are ready for working" << endl;
  21. QDebugStream cout(std::cout,logTextEdit);
  22. QDebugStream cerr(std::cerr,logTextEdit);
  23. }
To copy to clipboard, switch view to plain text mode 

Can anyone please let me know where am i making mistake. Or is there any other way to do the needful.

I will be grateful if helped--> Thanks in advance.