Search code examples
qtwebkitqwebview

How to debug QWebView's failure to load a web page?


I use QWebView to load a page, then I only keep reloading it with reload()slot. loadFinished(bool) signal often undicates false. I also use QwebView's network access manager's finished signal to get http response code - it's set to 0. The same page loads fine with all browsers, no matter how fast I try to relaod it in browser. How to debug this problem, what could be wrong?


Solution

  • Have you tried to get the reply's error code and error message, like this:

    class Browser(object):
    
        def __init__(self):
            self.network_manager = QNetworkAccessManager()
            self.network_manager.finished.connect(self._request_finished)
    
            self.web_page = QWebPage()
            self.web_page.setNetworkAccessManager(self.network_manager)
    
            self.web_view = QWebView()
            self.web_view.setPage(self.web_page)
    
        def _request_finished(self, reply):
            print reply.error()
            print reply.errorString()