문제

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?

도움이 되었습니까?

해결책

QTextCursor cursor = ui->DetailsTextBrowser->textCursor();
cursor.setPosition(0);
ui->DetailsTextBrowser->setTextCursor(cursor);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top