Format all instances of specific words in QTextEdit PySide6
Solved
General and Desktop
-
I've a bunch of words that needs to be formatted: emboldened, colored etc in a QTextEdit. How do I do it?
I tried the something like the following and quickly realized it only formats the first instance.
sync = self.editor.document().find("word") cf = QTextCharFormat() cf.setFontWeight(QFont.Bold) cf.setFontCapitalization(QFont.AllUppercase) sync.setCharFormat(cf) sync.clearSelection() self.editor.setTextCursor(sync)
Is QSyntaxHighligter the best/only option? I'm trying to avoid regex stuffs.
Please forgive me for there is not enough details. I'm in a hurry but I could update the post later.
Thank you.