Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll QTextBrowser to the top

I have the following:

QString html = ui->DetailsTextBrowser->document()->toHtml();
html = details.replace("#VERSION", "1.0");
ui->DetailsTextBrowser->document()->setHtml(details);

Unfortunately after the HTML content of the DetailsTextBrowser is set the document is scrolled to the bottom.

I tried without success:

ui->DetailsTextBrowser->verticalScrollBar()->setValue(0);

Is there a way to scroll QTextBrowser to the top?

like image 697
Gad D Lord Avatar asked Aug 23 '10 11:08

Gad D Lord


1 Answers

QTextCursor cursor = ui->DetailsTextBrowser->textCursor();
cursor.setPosition(0);
ui->DetailsTextBrowser->setTextCursor(cursor);
like image 146
Ivo Avatar answered Oct 20 '22 12:10

Ivo