Results 1 to 8 of 8

Thread: Rich text performance issue

  1. #1
    Join Date
    Apr 2009
    Posts
    21
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question Rich text performance issue

    Has anyone encountered performance issues when using rich text with html tags? I used either QLabel or QTextArea and passed in setText function an html string, with tags like, <table>, <font>. Leaving the program running overnight, the GUI ended taking 80% of the CPU. Removing the tags fixed the issue. While there's a work around, it'd be nice to use rich text.

    I'm using QtEmbedded 4.6.1

  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: Rich text performance issue

    If you don't do anything to the text or its surroundings that requires constat re-layouting the text, then no CPU power should be used on it regardless of the content of the text.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    cookie1909 (12th September 2012)

  4. #3
    Join Date
    Apr 2009
    Posts
    21
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Rich text performance issue

    I forgot to specify that the text is constantly updated very second to show the time. I have no performance issue when using plain text. But rich text would take up a lot of CPU. The bigger of the redrawing area is, the faster the CPU usage will increase.

  5. #4
    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: Rich text performance issue

    Quote Originally Posted by cookie1909 View Post
    I forgot to specify that the text is constantly updated very second to show the time. I have no performance issue when using plain text. But rich text would take up a lot of CPU. The bigger of the redrawing area is, the faster the CPU usage will increase.
    That seems quite normal, doesn't it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Apr 2009
    Posts
    21
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Rich text performance issue

    No, not quite

    For example:
    Updating a label holding a red text by using function label.setText("<font color=red>Some red text</font>"); every second takes up a lot of CPU usage.
    Drawing a label using palette.setColor(label.foregroundRole(), Qt::red); every second takes up almost nothing

    It would make sense to me if performance is similar either way, which is not in this case.

  7. #6
    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: Rich text performance issue

    In the second case you just draw text using a red pen. In the first case you have to parse HTML every now and then and do a bunch of other stuff. However I don't think drawing a red "Some red text" label takes that much cpu power. Your real use-case is much more complex.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    cookie1909 (12th September 2012)

  9. #7
    Join Date
    Apr 2009
    Posts
    21
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Rich text performance issue

    hmm so I thought about this again today and I'm still not convinced... if it always takes the same cpu usage all the time when parsing html then ok. But initially it'd take only 3%-4%, then overnight it'd take 70%-80%. It just seems like there's a memory leak somewhere while parsing html because with a red pen I don't have that problem.

    Appreciate your help, wysota

  10. #8
    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: Rich text performance issue

    Quote Originally Posted by cookie1909 View Post
    hmm so I thought about this again today and I'm still not convinced... if it always takes the same cpu usage all the time when parsing html then ok. But initially it'd take only 3%-4%, then overnight it'd take 70%-80%. It just seems like there's a memory leak somewhere while parsing html because with a red pen I don't have that problem.

    Appreciate your help, wysota
    Please post a minimal compilable example reproducing the problem and I'll happily inspect it for you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QTextEdit with html - rich text issue
    By kuku83 in forum Qt Programming
    Replies: 1
    Last Post: 23rd August 2012, 11:34
  2. QTabbar with rich text / html tab text
    By Berryblue031 in forum Qt Programming
    Replies: 1
    Last Post: 21st May 2012, 09:46
  3. QTextEdit + paste rich text as plain text only
    By Yong in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2008, 16:45
  4. Rich Text Format
    By Kapil in forum Newbie
    Replies: 1
    Last Post: 4th October 2006, 10:53
  5. Painting Rich Text
    By xanthine in forum Qt Programming
    Replies: 7
    Last Post: 15th April 2006, 23:35

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