Scrolling KTextEdit to launch

I have a KTextEdit filled with some text.

When I put a lot of text, the KTextEdit will automatically scroll to the end (obviously).

My question is, how can I go to the beginning (namely the first line of KTextEdit)?!?

0


source to share


2 answers


It looks like you are using

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

      



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

edit->moveCursor(QTextCursor::Start);

      

+1


source


The simplest way I can think of is:



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

      

0


source







All Articles