Setting textCursor position with line and column
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:
Code:
//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"
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
Re: Setting textCursor position with line and column
Use QTextCursor::NextBlock to go to the next line and you have to work with a copy of the cursor which has to be reset to to editor:
Code:
c.movePosition(/*...*/);
editor->setCursor(c);