Results 1 to 4 of 4

Thread: QTextEdit not being updated

  1. #1
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QTextEdit not being updated

    Hi,

    I've got a dialog which contains a QTextEdit.

    In the dialog's constructor, I call this->show(), then use a QProcess() to run an external process. I connect to the readyReadStandardOutput signal to update the QTextEdit with the QProcesses output. However the text is not being updated in the QTextEdit.

    If I activate and deactivate the dialog, by clicking on other windows on my system, everything updates, but if not, the dialog is not updated. The same code worked fine in QT3.

    regards,

    David

  2. #2
    Join Date
    Feb 2008
    Posts
    98
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 24 Times in 24 Posts

    Default Re: QTextEdit not being updated

    Could you post the code?

  3. #3
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit not being updated

    I've just found the problem, but i'm not sure what has caused it.

    In the new QT4 code (This is a port of an app from QT3 to QT4, that i've stared work on half way through).

    The dialog had the following functions defined in the header :-

    Qt Code:
    1. virtual void showEvent( QShowEvent* ShwEvt );
    2. virtual bool event( QEvent* Evt );
    To copy to clipboard, switch view to plain text mode 

    and in the cpp file

    Qt Code:
    1. void myclass::showEvent( QShowEvent* ShwEvt )
    2. {
    3. QDialog::showEvent( ShwEvt );
    4. QApplication::processEvents();
    5. }
    6.  
    7.  
    8. bool myclass::event( QEvent* Evt )
    9. {
    10. if ( Evt->type() == QEvent::Show )
    11. {
    12. /**
    13.   processing code, which I actually removed from here
    14.   so all it was doing was returning true.
    15.   **/
    16. return true;
    17. }
    18.  
    19.  
    20. return false;
    21. }
    To copy to clipboard, switch view to plain text mode 

    why would this code stop my screen updating? since removing it causes everything to be ok.

  4. #4
    Join Date
    Feb 2008
    Posts
    98
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 24 Times in 24 Posts

    Default Re: QTextEdit not being updated

    I think it's because event() is the main event handler, which is supposed to take care of all kinds of events. If you reimplement it and you don't call the parent class' event() method, your widget won't receive paint events among others, so paintEvent() is not invoked. I would recomment you to remove event() and just use showEvent().

Similar Threads

  1. QTextEdit Performance handling large paragraphs
    By netuno in forum Qt Programming
    Replies: 14
    Last Post: 1st September 2010, 23:58
  2. Drawing on QTextEdit
    By jgrauman in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2009, 10:40
  3. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 13:05
  4. Re-implement mouse events of QTextEdit
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2006, 17:55
  5. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 07:03

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.