As per the documentation, loadFinished should be emitted only after all the page elements have finished loading. This should mean that it'll be called only once, however I've noticed that on some sites like youtube.com, it gets called twice ? Is there any other way to get around this bug or whats the most reliable way to detect page.load event ?
Here's the test code :
import sys
from PyQt4 import QtCore, QtGui, QtWebKit
from PyQt4.QtCore import QUrl
from PyQt4.QtGui import QApplication
def onDone(val):
print "Done ...",val
def onStart():
print "Started..."
app = QApplication(sys.argv)
ui = QtWebKit.QWebView()
ui.loadStarted.connect(onStart)
ui.loadFinished.connect(onDone)
ui.load(QUrl("http://www.youtube.com"))
ui.showMaximized()
sys.exit(app.exec_())
The output:
Started...
Done ... True
Started...
Done ... True
Edit: There's an almost same question but its > 2yrs old and still unanswered.