titoaii
15th April 2010, 08:47
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:
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::NextCharact er, QTextCursor::MoveAnchor, 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
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:
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::NextCharact er, QTextCursor::MoveAnchor, 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