View Full Version : Highlight All line in QTextBrowser

29th June 2014, 17:38
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)
QTextCharFormat myClassFormat;
QColor backColor = QColor("Red");
myClassFormat.setProperty(QTextFormat::FullWidthSe lection, 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);

how can I do IT?