PDA

View Full Version : Rich text performance issue



cookie1909
4th September 2012, 20:49
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

wysota
12th September 2012, 09:40
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.

cookie1909
12th September 2012, 18:34
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.

wysota
12th September 2012, 22:56
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?

cookie1909
12th September 2012, 23:05
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.

wysota
12th September 2012, 23:11
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.

cookie1909
20th September 2012, 18:29
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 :)

wysota
20th September 2012, 21:04
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.