This snippet can only highlight current line, but it cannot highlight line with soft wraps.
screenshotscreenshot
def highlightCurrentLine(self):
extraSelections = []
if not self.isReadOnly() and self.toPlainText(): # and self.toPlainText()
selection = QTextEdit.ExtraSelection()
lineColor = QColor(Qt.yellow).lighter(160)
selection.format.setBackground(lineColor)
selection.format.setProperty(QTextFormat.FullWidthSelection, True)
selection.cursor = self.textCursor()
selection.cursor.clearSelection()
extraSelections.append(selection)
self.setExtraSelections(extraSelections)
This snippet can only highlight current line, but it cannot highlight line with soft wraps.
def highlightCurrentLine(self):
extraSelections = []
if not self.isReadOnly() and self.toPlainText(): # and self.toPlainText()
selection = QTextEdit.ExtraSelection()
lineColor = QColor(Qt.yellow).lighter(160)
selection.format.setBackground(lineColor)
selection.format.setProperty(QTextFormat.FullWidthSelection, True)
selection.cursor = self.textCursor()
selection.cursor.clearSelection()
extraSelections.append(selection)
self.setExtraSelections(extraSelections)
This snippet can only highlight current line, but it cannot highlight line with soft wraps.
screenshot
def highlightCurrentLine(self):
extraSelections = []
if not self.isReadOnly() and self.toPlainText(): # and self.toPlainText()
selection = QTextEdit.ExtraSelection()
lineColor = QColor(Qt.yellow).lighter(160)
selection.format.setBackground(lineColor)
selection.format.setProperty(QTextFormat.FullWidthSelection, True)
selection.cursor = self.textCursor()
selection.cursor.clearSelection()
extraSelections.append(selection)
self.setExtraSelections(extraSelections)
QPlainTextEdit highlight current line with soft wraps?
This snippet can only highlight current line, but it cannot highlight line with soft wraps.
def highlightCurrentLine(self):
extraSelections = []
if not self.isReadOnly() and self.toPlainText(): # and self.toPlainText()
selection = QTextEdit.ExtraSelection()
lineColor = QColor(Qt.yellow).lighter(160)
selection.format.setBackground(lineColor)
selection.format.setProperty(QTextFormat.FullWidthSelection, True)
selection.cursor = self.textCursor()
selection.cursor.clearSelection()
extraSelections.append(selection)
self.setExtraSelections(extraSelections)
lang-py