Reputation: 2499
I'd like to force a redraw over a QPlainTextEdit widget, because my highlighting rules changed. However, all lines and blocks aren't redrawn, respecting the new rules.
This is true because if I modify a line, the correct highlighting is applied, and I am happy. But I cannot force-modify each block to see any change!
Is there a way to force a redraw? I tried update() and similars, but nothing seems to work.
Thanks!
Upvotes: 3
Views: 3487
Reputation: 11558
In my case simply calling rehighlight don't update view. In my case i want update highlight when cursor moves so:
void MyHighlighter::onSelectionChanged(int start, int end)
{
_visibleCursor.setPosition(end);
document()->documentLayout()->updateBlock(_visibleCursor.block());
rehighlightBlock(_visibleCursor.block());
}
Upvotes: 0
Reputation: 956
You have to call QSyntaxHighlighter::rehighlight()
to apply the new highlighting rules to the whole document.
Upvotes: 1
Reputation: 40512
QPlainTextEdit inherits QAbstractScrollArea, so its content is located in viewport widget. Try this:
text_edit->viewport()->update();
Upvotes: 7