Scroll QTextBrowser to the top
Asked Answered
P

1

10

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?

Pansypant answered 23/8, 2010 at 11:45 Comment(1)
im curious to know why the other methods do not work.Weismann
D
16
QTextCursor cursor = ui->DetailsTextBrowser->textCursor();
cursor.setPosition(0);
ui->DetailsTextBrowser->setTextCursor(cursor);
Devonna answered 23/8, 2010 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.