vuletic
28th March 2015, 15:25
Hello, I'm trying to "paint" everything between /* and */, with this code:
self.plainTextEdit.moveCursor(self.plainTextEdit.f ind("/*"),QtGui.QTextCursor.MoveAnchor)
self.plainTextEdit.moveCursor(self.plainTextEdit.f ind("*/") ,QtGui.QTextCursor.KeepAnchor)
cursor = self.plainTextEdit.textCursor()
currentWord = QtWidgets.QTextEdit.ExtraSelection()
yellowColor = QtGui.QColor("yellow")
currentWord.format.setForeground(yellowColor)
currentWord.cursor = cursor
extraSelections.append(currentWord)
But I get this: http://i.imgur.com/ObSvmj5.png
it seems for some reason, MoveAnchor is not moving to /* location, but from start, can someone explain how can this be fixed?
self.plainTextEdit.moveCursor(self.plainTextEdit.f ind("/*"),QtGui.QTextCursor.MoveAnchor)
self.plainTextEdit.moveCursor(self.plainTextEdit.f ind("*/") ,QtGui.QTextCursor.KeepAnchor)
cursor = self.plainTextEdit.textCursor()
currentWord = QtWidgets.QTextEdit.ExtraSelection()
yellowColor = QtGui.QColor("yellow")
currentWord.format.setForeground(yellowColor)
currentWord.cursor = cursor
extraSelections.append(currentWord)
But I get this: http://i.imgur.com/ObSvmj5.png
it seems for some reason, MoveAnchor is not moving to /* location, but from start, can someone explain how can this be fixed?