Results 1 to 9 of 9

Thread: [QT 4] QTextEdit performance

  1. #1
    Join Date
    Feb 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default [QT 4] QTextEdit performance

    I tell ya what I am not that impressed with the QTextEdit performance. I have a thread running some code and all it does is send a msg to my GUI (append to QTextEdit) and it doesn't update at all until after my thread is completed.

    I've read that other people have said the performance is bad but was told to use a QTable.

    Why use a QTable when QTextEdit is really what I want? hmm...

    Is there a way to improve the speed of updating. I have a QProgressbar and it gets a call at the same time I send a call to the QTextEdit (while the progressbar updates great the textedit does not.)

    Anythoughts?

  2. #2
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QT 4] QTextEdit performance

    Quote Originally Posted by fellobo
    I tell ya what I am not that impressed with the QTextEdit performance. I have a thread running some code and all it does is send a msg to my GUI (append to QTextEdit) and it doesn't update at all until after my thread is completed.

    I've read that other people have said the performance is bad but was told to use a QTable.

    Why use a QTable when QTextEdit is really what I want? hmm...

    Is there a way to improve the speed of updating. I have a QProgressbar and it gets a call at the same time I send a call to the QTextEdit (while the progressbar updates great the textedit does not.)

    Anythoughts?
    Seems to work fast enough for me. The "qQpp->processEvents();" call updates the QTextEdit control as fast as the Windows events que will allow.
    Qt Code:
    1. ui.leStatus->setText("Preparing XTab Report...");
    2. this->setCursor(Qt::WaitCursor);
    3. qApp->processEvents();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [QT 4] QTextEdit performance

    hmmm, I am using the QTextEdit::append(QString); I wonder if that is why.....

    it would look like this:
    Qt Code:
    1. for(int x = 0; x < 1000; x++)
    2. {
    3. my_qtext_edit_ptr->append(tr("this is another line %1").arg(x));
    4.  
    5. QTextCursor cursor(my_qtext_edit_ptr->textCursor());
    6. cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
    7. my_qtext_edit_ptr->setTextCursor(cursor);
    8.  
    9. // although I've had this in there it didn't seem to help much
    10. QApplication::processEvents();
    11.  
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 

    I will go and try this exact thin and post my results....
    And thanks for replying to my post.

  4. #4
    Join Date
    Feb 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [QT 4] QTextEdit performance

    Good test, I set it up and it ran like I expected it to (fast and good.) But then I started to change things. What I have is a thread, right, so the way my thread sends the message back is threw and signal and a slot.

    I placed within my thread the for loop and had it send back the message back via emit and it gave the display. So, would it be in the emit or would it be within the thread?

    My thread is very simple thread.
    Qt Code:
    1. // with in the basic run I have
    2. for(int x = 0; x < 1000; x++)
    3. {
    4. send(tr("I want more lines\nthis is another line %1").arg(x));
    5. }
    6.  
    7. // where send is a function
    8.  
    9. void my_thread::send(QString msg)
    10. {
    11. emit send_msg(msg);
    12. }
    To copy to clipboard, switch view to plain text mode 

    now my connect on my gui looks like this
    Qt Code:
    1. connect(mp_thread, SIGNAL(send_msg(QString)), this,
    2. SLOT(append_output(QString)));
    3.  
    4. // and my funciton
    5.  
    6. void my_gui::append_output(QString out_msg)
    7. {
    8. output_text->append(out_msg);
    9.  
    10. QTextCursor cursor(output_text->textCursor());
    11. cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
    12. output_text->setTextCursor(cursor);
    13. QApplication::processEvents();
    14. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QT 4] QTextEdit performance

    Quote Originally Posted by fellobo
    Qt Code:
    1. // with in the basic run I have
    2. for(int x = 0; x < 1000; x++)
    3. {
    4. send(tr("I want more lines\nthis is another line %1").arg(x));
    5. }
    To copy to clipboard, switch view to plain text mode 

    What happens if you put a sleep(0) in that loop?
    Save yourself some pain. Learn C++ before learning Qt.

  6. #6
    Join Date
    Feb 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [QT 4] QTextEdit performance

    I placed a dealy for a second and it improved the look of it but still lagged down.

    So yes, if I slowed down added/emit call then it will have time to update. I was thinking that maybe the QTextEdit has a lower priority then that of the Thread or even the progress bar for that matter.

    I haven't tried it yet but was thinking of placing the thread at a low priority (not sure if this will fix things or even how low to put it.)

    Any ideas?

  7. #7
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QT 4] QTextEdit performance

    Quote Originally Posted by fellobo
    I placed a dealy for a second and it improved the look of it but still lagged down.
    sleep(1) is okay, but I specifically meant sleep(0), this causes the thread to yield to any other running threads and continue execution as quickly as possible. It's a common technique in thread management. Your sleep(1) will cause a 1-second delay between iterations of the loop, even when it is not necessary.

    I'm not sure that your problem is to do with threading anyway. It maybe just that QTextEdit cannot handle new data and repainting at the rate that you are sending it. Have you tried using setUpdatesEnabled(bool) to periodically allow the widget to redraw?
    Save yourself some pain. Learn C++ before learning Qt.

  8. #8
    Join Date
    Jan 2006
    Location
    New Malden (near London)
    Posts
    32
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: [QT 4] QTextEdit performance

    I have a huge problem with QTextEdit's performance also. Text editing is a major part of my app and when typing text into a QTE widget, you notice a lag between you typing and the letter appearing. This leads to a reduction in typing accuracy as well. It's very irritating. Trolltech said in the changelog that the widget in 4.1.1 had improved performance, but I don't notice it. (I use Qt/Mac but when using it on X11 similar problems appear.) The problem is sometimes worse than at other times.

  9. #9
    Join Date
    Feb 2006
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [QT 4] QTextEdit performance

    Hello,

    I can also confirm the bad QTextEdit performance here on linux.
    As said before, sometimes there's just a lag in typing, sometimes there is no lag. The bigger the text gets, the worse the problem. Even 50k or less gets slow here. This is very odd because I have 3.2ghz and a text widget (just showing regular text) shouldn't show any noticable slowdown, even with megs of text inside. Let's just hope 4.2 will fix the issue..

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. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 07:03
  5. Increasing performance from Qtextedit, listview, etc?
    By taylor34 in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2006, 11:20

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.