Note that there are some explanatory texts on larger screens.

plurals
  1. POOverride shouldInterruptJavaScript in QWebPage with PySide
    text
    copied!<p>I would like to override PySide.QtWebKit.QWebPage.shouldInterruptJavaScript() slot to silently ignore JavaScript interrupt requests. I have my own timeout timer setup and I do not need a default message dialog.</p> <p>Quoting PySide <a href="http://www.pyside.org/docs/pyside/PySide/QtWebKit/QWebPage.html#PySide.QtWebKit.PySide.QtWebKit.QWebPage.shouldInterruptJavaScript" rel="nofollow">documentation</a>:</p> <blockquote> <p>Because of binary compatibility constraints, this function is not virtual. If you want to provide your own implementation in a PySide.QtWebKit.QWebPage subclass, reimplement the QWebPage.shouldInterruptJavaScript() slot in your subclass instead. QtWebKit will dynamically detect the slot and call it.</p> </blockquote> <p>This is an example code I wrote, but my shouldInterruptJavaScript() method is never called. I see the same code used in PhantomJS and webscraping open source projects.</p> <pre><code>import sys from PySide import QtCore from PySide.QtGui import QApplication from PySide.QtWebKit import QWebPage class QWebPageHeadless(QWebPage): # FIXME: This is not working, the slot is not overriden! @QtCore.Slot() def shouldInterruptJavaScript(self): print "Interrupt javascript request ignored..." return False if __name__ == "__main__": app = QApplication(sys.argv) page = QWebPageHeadless() page.mainFrame().setHtml('&lt;script&gt;while(1);&lt;/script&gt;') sys.exit(app.exec_()) </code></pre> <p>I have Python 2.7.1, PySide 1.0.2, Qt 4.7.2. Right now I am building the latest PySide so I can test it, but I can not find anything about shouldInterruptJavaScript in recent release notes or bug reports.</p> <p><strong>Is there something special how should I reimplement shouldInterruptJavaScript in my subclass?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload