PDA

View Full Version : Best performance when comparing two QTextEdits



leenxkewl
16th October 2010, 16:36
Hello :)

I want to compare the contents of two QTextEdits. Basically, this is for a difference view of a text editor. The user can open a second file that syncs with the first (ie. scrolling), what I have done already. Now I want to mark all lines with a yellow background in the second QTextEdit that are different from the according line in the first one. I can think of several ways to do this, but which is the most performant?

tbscope
16th October 2010, 16:41
How big can these textfiles be?
What is the general size of a textfile?

leenxkewl
16th October 2010, 18:53
Well, we're talking of maybe 100k lines max. The general size will be like 10k lines, each line having up to 40-50 characters. Actually a scalable solution would be to only perform on the visible text, so the final size of the QTextEdit would not really matter.

tbscope
16th October 2010, 19:07
I would use QtConcurrent to run the processing outside the main event loop.

Have a look at the longest common subsequence algorithm.