Problems with textfinder example
-
First is when I change QTextDocument::FindWholeWords to QTextDocument::FindFlag(0).
It highlight from found substring to end of word.
I know it is becausehighlightCursor.movePosition(QTextCursor::WordRight, QTextCursor::KeepAnchor);
I must move right of substring len; is any better way than N call following?
highlightCursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
Second problem is worse: while in exmaple
colorFormat.setForeground(Qt::red);
works fine, in my editor this not works, only works
colorFormat.setBackground(Qt::yellow);
maybe because I have highlighter?
Third problem: after highlighting found substring, text has flag isModified.
in example at start is// undo previous change (if any) document->undo();`
How correctly handle it? Document can have real change or not.
-
-
Best result are without highlightCursor.movePosition because highlightCursor = plainEdit->document()->find() is enough.
I don't know why colorFormat.setForeground(Qt::red) doesn't work while colorFormat.setBackground(Qt::yellow) worksPartial solution: If I removed highlighter, my foreground color changed to red
But how to use highlighter and themes (I am using themes from KF5SyntaxHighlighting) to change it?