[Qt-interest] Advice sought for a text viewer application

Martin Matusiak numerodix at gmail.com
Thu Oct 1 22:57:03 CEST 2009


Hello,

So what I'm doing is a text viewer, not so much editor. When I want to
load a new document (using QTextEdit to render) I index the whole file
with a regex to find words of interest. Then I want to display these
words highlighted in the document (interactively, so the user can pick
one at a time to highlight). Now, in order to handle sizable files I
obviously don't want to store the whole file in memory. So my question
is what do you recommend to do about displaying chunks of the document
at a time? How can I coordinate what is in the viewport vs the
position in the document so that I can load chunks as needed?

I also need a better way to highlight words than to cycle through
every instance of the word in the document, grab a QTextCursor,
highlight, set formatting, and then move on to the next. This just
takes too long to do in a large document. It should be done lazily to
only format the part that needs to be displayed in the viewport.

If it makes any difference, I'm using pyqt.

Your thoughts?


Martin



More information about the Qt-interest-old mailing list