scrolling KTextEdit to start

96 views Asked by At

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) ?!?

2

There are 2 answers

0
Johannes Schaub - litb On BEST ANSWER

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);
0
user11323 On

The simplest way i can think of is:

KTextEdit *kte;
...
kte->append("some huge text");
kte->verticalScrollBar()->setValue(0);