I would like to underline something in a QTreeWidget with a red wave like this :
I tried to pull this off with a QTextCursor but apparently it's not possible. Anyone knows another way ?
As an exemple, here is a way to underline a word with QTextCursor :
import sys
from PyQt5.QtCore import *
from PyQt5 import QtWidgets, QtGui, uic
def drawGUI():
app = QtWidgets.QApplication(sys.argv)
w = QtWidgets.QWidget()
editBox = QtWidgets.QTextEdit(w)
text = 'THE_WORD'
editBox.setText(text)
cursor = editBox.textCursor()
format_ = QtGui.QTextCharFormat()
format_.setUnderlineStyle(QtGui.QTextCharFormat.WaveUnderline)
regex = QRegExp('\\bTHE_WORD\\b')
index = regex.indexIn(editBox.toPlainText(), 0)
cursor.setPosition(index)
cursor.movePosition(QtGui.QTextCursor.EndOfWord, 1)
cursor.mergeCharFormat(format_)
w.show()
sys.exit(app.exec_())
if __name__ == '__main__':
drawGUI()