[PyQt] Synchronous WebView.load()

alanm me at alandmoore.com
Thu Jul 1 20:13:47 BST 2010


I have an app with a QWebView, and I'm trying to implement a "reset" button 
that will clear the history and return the user to the start page.

The method looks like this:

def reset_browser(self):
    self.webview.load(self.startUrl)
    self.webview.history().clear()

The problem with the method is that QWebView.load() is asynchronous; so the 
page starts loading, then the history clears, then the page finishes loading 
and the previous page is put in to history.  The net result is that the last 
page visited before the reset is still in history.

I can see solutions to this problem if there is a way to:
  - Tell load() to run synchronously
  - Tell history to clear everything, including the current page

Any thoughts?


More information about the PyQt mailing list