Search code examples
linuxqtkdelibs

scrolling KTextEdit to start


I have a KTextEdit, filled with some text.

When I put lots of text, the KTextEdit will be scrolled automatically to the end (obviously).

My question is: how can I scroll to the start (viz to the first line of the KTextEdit) ?!?


Solution

  • Looks like you use

    QTextCursor cursor = edit->textCursor();
    cursor.setPosition(0);
    edit->setTextCursor(cursor);
    

    Not tested, but looks fine. Found another, shorter way:

    edit->moveCursor(QTextCursor::Start);