QML textedit/textarea style a text (bold, italic) without highlighting
-
our application needs to detect some words while user types in a textarea, and when it is detected it is converted to bold and/or italic. I can see in QML text editor example, it can be done using document Handler but it works when it is highlighted.
I assume I will use the richtext format for text area, but I cant simply manipulate the HTML from textArea.txt because it includes headers and what not,
How do I effectively do this?
somewhat like the steps,
detectwordsTyped()
detectPositionOfWords()
bold the words by <b> words </b>any idea how to do this?
-
Use QSyntaxHighlighter (you need to expose it to QML through a custom subclass). It will handle the highlighting part automatically, you just need to set up the rules.