Is there a bug in following behavior of QWebView / QWebPage?<br><br>PROGRAM 1:<br>----------------------------------<br><br>import sys<br>from PyQt4.QtGui import *<br>from PyQt4.QtCore import *<br>from PyQt4.QtWebKit import QWebView<br>
<br>if __name__ == "__main__":<br> app = QApplication(sys.argv)<br> <br> def on_load_finished(*args):<br> print("on load finish called")<br> <br> webview = QWebView()<br> webview.show()<br>
QObject.connect(webview.page(), SIGNAL("loadFinished(bool)"), on_load_finished )<br> webview.page().mainFrame().load(QUrl('<a href="http://www.google.com/ncr'">http://www.google.com/ncr'</a>))<br>
app.exec_()<br><br>--------------------------------------<br><br>In this case, the "on_load_finished" function is NOTcalled<br><br>However, if I cache the page, like following, <br><br>PROGRAM 2<br>----------------------------------------<br>
<br>import sys<br>from PyQt4.QtGui import *<br>from PyQt4.QtCore import *<br>from PyQt4.QtWebKit import QWebView<br><br>if __name__ == "__main__":<br> app = QApplication(sys.argv)<br> <br> def on_load_finished(*args):<br>
print("on load finish called")<br> <br> webview = QWebView()<br> webview.show()<br> page = webview.page() #THIS LINE WAS ADDED<br> QObject.connect(webview.page(), SIGNAL("loadFinished(bool)"), on_load_finished )<br>
webview.page().mainFrame().load(QUrl('<a href="http://www.google.com/ncr'">http://www.google.com/ncr'</a>))<br> app.exec_()<br>------------------------------------------<br><br>Then the on_load_finished function DOES get called in this case<br>
<br>why the odd behavior? issit some sort of bug or issit just something I am not aware of? I tried looking up the documentation but there is nothing documenting this behavior.<br><br>Thanks for reading. <br><br><br><br><br>