Results 1 to 4 of 4

Thread: QTextEdit from cout stream not displayed at once

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb QTextEdit from cout stream not displayed at once

    Dear all,
    I search in the web and I found out that a way to redirect std::cout to a QTextEditor is to implement a class
    Qt Code:
    1. class QDebugStream : public std::basic_streambuf<char>
    To copy to clipboard, switch view to plain text mode 
    The implementation of the class is in the attached file.
    I made the call of the class in this way (Ui_outputView I designed myself through qtDesigner, it is just a Widget containing a QTextEditor "consoleTextEdit")
    Qt Code:
    1. class OutputView : public QWidget, private Ui_outputView
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. OutputView(QWidget* parent = NULL){
    7. setupUi(this);
    8. consoleTextEdit->toPlainText();
    9. qout = new QDebugStream(std::cout, consoleTextEdit);
    10. }
    11. ~OutputView(){}
    12.  
    13. private:
    14. QDebugStream *qout;
    15.  
    16. };
    To copy to clipboard, switch view to plain text mode 

    The code works fine, I can display the output text but I have two main questions:
    1- I would like that the text is displayed not all at once: so far the text is displayed when the function that contains all the prints "cout<<" returns. I would like to see the output as in happen in the console when the cout is called.
    2- is it worth perhaps to use QTextStream to catch the standard output and display it in a QTextEdit? Any hints on how to do that?

    Thanks in advance for your help, if something is not clear please let me know.
    Regards,
    Annalisa
    Attached Files Attached Files

Similar Threads

  1. Qt Creator where is cout in Qt Creator
    By hqking1988 in forum Qt Tools
    Replies: 8
    Last Post: 12th September 2019, 22:32
  2. where is cout
    By hqking1988 in forum General Programming
    Replies: 3
    Last Post: 22nd August 2010, 03:35
  3. Replies: 4
    Last Post: 27th March 2008, 09:21
  4. cout problem
    By mickey in forum General Programming
    Replies: 3
    Last Post: 2nd March 2007, 18:12
  5. How to cout in Qt ?
    By probine in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2006, 00:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.