Results 1 to 5 of 5

Thread: QTextEdit slow to insert text

  1. #1
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTextEdit slow to insert text

    I've got an application that uses a QTextEdit that gets text inserted in it, often only 4-20 characters at a time quite frequently. Normally, I'm setting a different color, inserting about 20 characters, changing colors, inserting more text, etc. Problem is that the text inserts pretty slowly. I'd say it takes about 100 lines of differently colored text about 1sec to be drawn in. Thats running on my laptop ~PentiumM 1.7Ghz. It just seems really, really slow. As far as I can tell, it seems to be a problem with the QTextEdit just being slow. I read somewhere that theres some horrible performance issues with the scrollbars. I'm trying to append text to the QTextEdit and keep the QTextEdit scrolled down to the bottom of the text, So I'm often calling
    Qt Code:
    1. QTextEdit->verticalScrollbar->setValue( mp_scrollBar->maximum() );
    To copy to clipboard, switch view to plain text mode 
    I'm inserting all plaintext, no HTML by the QTextEdit's insertPlainText method... Am I doing this the wrong way? Should I be inserting text into the QTextDocument that the QTextEdit uses instead? Or is the QTextEdit just slow for inserting new text?

    Thanks,
    Paul

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit slow to insert text

    Your method is fine. Are you sure the slowdown is caused by inserting text and nothing else?

  3. #3
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTextEdit slow to insert text

    That was stupid of me. I was calling qApp->processEvents() everytime text was inserted. I was doing that back when I was stepping through my code and wanted to see the updated text immediately. Removed the call and now it flys ;p

    Paul

  4. #4
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTextEdit slow to insert text

    One related question. Is there a way to tell Qt to process GUI events for a specific widget? SO instead of saying qApp->processEvents() I could just do myWidget->processEvents() ??

    Paul

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit slow to insert text

    You can use QCoreApplication::sendPostedEvents() if you want.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  3. Replies: 3
    Last Post: 20th November 2007, 07:03
  4. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03
  5. Problem with inserting text into QTextEdit
    By xorrr in forum Qt Programming
    Replies: 0
    Last Post: 6th February 2006, 11:45

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.