I think you are mixing up "Replace All" and "Auto Correction/Formatting" features, better to implement them separately.
Method to find and replace: Use toPlainText(), replace the text and then it back setPlainText(). If using this inside a slot connected to contentsChange() signal, take care to blockSignals(true), and blockSignals(false) guard statements while setting the new text to avoid recursion.
Qt Code:
MyTextDocument::on_contentsChange() { blockSignals(true); // find and replace in text setPlainText(text); blockSignals(false); }To copy to clipboard, switch view to plain text mode






Reply With Quote

Bookmarks