Is there any way to control the keyboard cursor in QTextEdit? For instance move the cursor one line up, or two positions back. I have looked at the QCursor class, but is this only for the mouse cursor? Thanks!
0
votes
2 Answers
4
votes
QTextCursor::movePosition(MoveOperation operation, MoveMode mode=MoveAnchor, int n=1)
This method allows you to move the cursor in various ways, such as one word to the right or up one line.
You can use it like this:
QTextCursor c = textEdit->textCursor();
c.movePosition(QTextCursor::Up);
textEdit->setTextCursor(c);
If you need to select some text, not just move the cursor, specify the MoveMode as KeepAnchor.
1
votes