How to highlight differently two views of the same QTextDocument
Hello everyone !
I found already a lot of answers on this forum, but I'm stuck on this issue :
I'm trying to implement a sort of text "minimap" as we can find in Kate or Sublime Text (more the latter) .
From a single QTextDocument, I display it in a QTextEdit (editor) and also in a QTextBrowser (minimap) . The minimap uses QGraphicsView and QGrapicsProxyWidget to be seen scaled down. It works fine.
Now, I want to apply a different highlighting to each of the views. I read everywhere that I can't use two QSyntaxHighlighter in the same QTextDocument. Fine, having already use this class, I understand the limitation. Yet, I don't want to clone the QTextDocument each time there is an update, only for it to support it's own highlighter. It would be resource hungry with large texts.
Does anyone have an idea ? Maybe a workaround or a different approach ? I'd like to read your input
Thank you for your time and "Vive Qt !"
Re: How to highlight differently two views of the same QTextDocument
What exactly do you want to highlight differently? The whole text or do you mean selections?
Re: How to highlight differently two views of the same QTextDocument
Hello wysota,
A whole different set of fonts and colors for all of the document.
Re: How to highlight differently two views of the same QTextDocument
I'm afraid in that case you will have to make a copy of the document and synchronize both documents by handling QTextDocument::contentsChange() signal.
Re: How to highlight differently two views of the same QTextDocument
Thank you, I was afraid of that.