I use this code below to highlight the select text in text Browser.
the var selectLine have a text to highlight, but i want select all line width in editor with this text not just a selected text
void MyHighlighter
::highlightBlock(const QString &text
) {
myClassFormat.setBackground(backColor);
myClassFormat.
setProperty(QTextFormat::FullWidthSelection,
true);
int index = text.indexOf(expression);
while (index >= 0) {
int length = expression.matchedLength();
setFormat(index, length , myClassFormat);
index = text.indexOf(expression, index + length);
}
}
}
void MyHighlighter::highlightBlock(const QString &text)
{
QTextCharFormat myClassFormat;
QColor backColor = QColor("Red");
myClassFormat.setBackground(backColor);
myClassFormat.setProperty(QTextFormat::FullWidthSelection, true);
QString pattern = selectLine;
QRegExp expression(pattern);
int index = text.indexOf(expression);
while (index >= 0) {
int length = expression.matchedLength();
setFormat(index, length , myClassFormat);
index = text.indexOf(expression, index + length);
}
}
}
To copy to clipboard, switch view to plain text mode
how can I do IT?
Bookmarks