void CodeEditor::highlightCurrentLine()
{
QList<QTextEdit::ExtraSelection> extraSelections;
if (!isReadOnly()) {
selection.format.setBackground(lineColor);
selection.
format.
setProperty(QTextFormat::FullWidthSelection,
true);
selection.cursor = textCursor();
selection.cursor.clearSelection();
extraSelections.append(selection);
}
// BEGIN: added
currentWord.format.setBackground(redColor);
currentWord.cursor = cursor;
extraSelections.append(currentWord);
// END: added
setExtraSelections(extraSelections);
}
void CodeEditor::highlightCurrentLine()
{
QList<QTextEdit::ExtraSelection> extraSelections;
if (!isReadOnly()) {
QTextEdit::ExtraSelection selection;
QColor lineColor = QColor(Qt::yellow).lighter(160);
selection.format.setBackground(lineColor);
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
selection.cursor = textCursor();
selection.cursor.clearSelection();
extraSelections.append(selection);
}
// BEGIN: added
QTextCursor cursor = textCursor();
cursor.select(QTextCursor::WordUnderCursor);
QTextEdit::ExtraSelection currentWord;
QColor redColor = Qt::red;
currentWord.format.setBackground(redColor);
currentWord.cursor = cursor;
extraSelections.append(currentWord);
// END: added
setExtraSelections(extraSelections);
}
To copy to clipboard, switch view to plain text mode
Bookmarks