Reputation: 692
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!
Upvotes: 0
Views: 569
Reputation: 34116
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.
Upvotes: 4
Reputation: 2621
Yes there is:
http://doc.qt.nokia.com/4.7-snapshot/qtextedit.html#moveCursor
Upvotes: 1