QtWidgets.QTextEdit.textCursor().movePosition(); how to define the exact number of characters?

A method to find a substring and highlight it in QTextEdit has already been proposed in stackoverflow by vicent.

This is an elegant and effective method. However as it is used:

cursor.movePosition(QtGui.QTextCursor.EndOfWord, 1)

the highlighting goes to the end of the word where the substring is detected.

I am looking for a way to define the exact number of characters. Something like this (doesn't work!):

cursor.movePosition(len(pattern), 1)

to highlight only the substring.

Read more here: https://stackoverflow.com/questions/67928919/qtwidgets-qtextedit-textcursor-moveposition-how-to-define-the-exact-number

Content Attribution

This content was originally published by servoz at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: