Hello everybody,
I'm trying to move the cursor of a QTextEdit to a position that is specified with line number and column. I've tried with movePosition() in the QTextCursor like this:
//Moves the cursor to the beginning of the document
editor
->textCursor
().
setPosition(0,
QTextCursor::MoveAnchor);
//Now moves the cursor to the line "line" and in the column "index"
QTextEdit * editor;
//Moves the cursor to the beginning of the document
editor->textCursor().setPosition(0,QTextCursor::MoveAnchor);
//Now moves the cursor to the line "line" and in the column "index"
editor->textCursor().movePosition(QTextCursor::Down, QTextCursor::MoveAnchor,line-1);
editor->textCursor().movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, index);
To copy to clipboard, switch view to plain text mode
However, the only thing I get with this is the cursor in the same position as the beginning.
Does anybody know how to achieve this??
Thank you in advance!
Alberto
Bookmarks