I guess this should be a simple task: change a QWebView's content (it always contains several pages of stuff) then scroll the page back in the previous position:
y = self.webView.page().mainFrame().scrollPosition().y()
self.webView.setHtml(looong_html_text)
if y != 0:
self.webView.scroll(0, y)
self.webView.page().mainFrame().scroll(0, y)
self.webView.page().mainFrame().setScrollPosition(QPoint(0, y))
print(self.webView.page().mainFrame().scrollPosition().y())
But the 3 commands inside the if are completely useless: the page scrolls back to top. What's wrong?