开发者

Scroll QTextBrowser to the top

开发者 https://www.devze.com 2023-01-13 04:40 出处:网络
I have the following: QString html = ui->DetailsTextBrowser->document()->toHtml(); html = details.replace(\"#VERSION\", \"1.0\");

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 DetailsTextBrowse开发者_C百科r 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?


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

精彩评论

暂无评论...
验证码 换一张
取 消