Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to know "what changed" in QSyntaxHighlighter::highlightBlock() method?



  • I am trying to use QSyntaxHighlighter to implement a spell checker.
    I see that highlightBlock() is called for every change in the block, and I am required to perform spell check for all the words to highlight the wrong ones.

    I feel that, this is wasteful.

    I see, that all the words other than the one being currently edited, are unchanged. Even then I have to perform the same operation for every key press. All the words before the edit position have not moved ... so I wish to copy the existing highlighting to them blindly. I think I can do the same for the words following the being-edited word.....just by shifting the format forward one step (for normal typing) or backwards one step (for delete or backspace). However this will become tricky in the case of cut-paste operations that remove or insert unknown number of characters.

    Is there any way to know what is being changed? how much and where? Please let me know.
    Thanks in advance.


Log in to reply