Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Replace text from where user left the cursor
haney last edited by
I developed a Find/Replace feature for my editor. In case of replaceText(), the text is being replaced from the start of the document. Ideally, it should start replacing from where the user left the cursor position. Please help me regarding this.
void MyEditor::replaceText(const QString &findWord, const QString &replaceWord)
I need to start replacing text not from START of doc, but from where user had left the cursor.
 code wrappings added, koahnig
koahnig last edited by
Please use "code wrappings":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 when posting code sections
goetz last edited by
You could work with the find() methods of the [[Doc:QTextDocument]] attached to the QTextEdit. Those methods take a [[Doc:QTextCursor]] or int argument as the starting point of the search.