[PyQt] Overriding shouldInterruptJavaScript

Phil Thompson phil at riverbankcomputing.com
Wed Aug 10 10:28:00 BST 2011


On Tue, 9 Aug 2011 10:35:11 -0700, Brian Zambrano <brianz at gmail.com>
wrote:
> In my QWebPage, I'd like to override the shouldInterruptJavaScript
method
> so
> that it ignores long running javascript warning.
> 
>
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebpage.html#shouldInterruptJavaScript
> 
> *Warning:* Because of binary compatibility constraints, this function is
> not
>> virtual. If you want to provide your own implementation in a
>>
QWebPage<http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebpage.html>
>> subclass,
>> reimplement the shouldInterruptJavaScript() slot in your subclass
>> instead.
>>
QtWebKit<http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtwebkit.html>
>> will
>> dynamically detect the slot and call it.
> 
> 
> However, when I override it, it appears to never be called.
> 
> class DebugWebPage(QWebPage):
> 
>     @pyqtSlot(bool)
>     def shouldInterruptJavaScript(self):
>         print 'not interrupting'
>         return False
> 
> It looks like someone else hit the same issue with PySide:
> 
>
http://stackoverflow.com/questions/6868286/override-shouldinterruptjavascript-in-qwebpage-with-pyside
> 
> I'm tried with and without the pyqtSlot decorator with the same results.
> 
> Insight appreciated,
> BZ

You can't override non-virtual methods.

Phil


More information about the PyQt mailing list