how do I highlight the current line in QScintilla

525 Views Asked by At

I want to highlight the current line (the line the caret is in, similar to Notepad++) in QScintilla. Searching the interwebs gave nothing at all. Am I missing something obvious?

qscintillaWidget = QsciScintilla(parent = self)
qscintillaWidget.highlightCurrentLine(True)  # <- something like this
2

There are 2 best solutions below

0
shao.lo On BEST ANSWER

Enable and then choose a color.

qscintillaWidget.setCaretLineVisible(True)
qscintillaWidget.setCaretLineBackgroundColor(QtGui.QColor('lightblue'))
0
Rida Shamasneh On

Another way to highlight a specific line in QScintilla is to use Indicators: https://qscintilla.com/#clickable_text/indicators

DEFAULT_INDICATOR_ID = 1
self.__editor.indicatorDefine(QsciScintilla.FullBoxIndicator, DEFAULT_INDICATOR_ID)
self.__editor.fillIndicatorRange(line_number, 0, line_number+1, 0, DEFAULT_INDICATOR_ID)