我想重写PySide.QtWebKit.QWebPage.shouldInterruptJavaScript()slot以静默方式忽略JavaScript中断请求。我有我自己的超时计时器设置,我不需要一个默认的消息对话框。在
引用PySidedocumentation:
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.
这是我编写的示例代码,但我的shouldInterruptJavaScript()方法从未被调用。我在PhantomJS和Web垃圾开源项目中看到了相同的代码。在
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('<script>while(1);</script>')
sys.exit(app.exec_())
我有python2.7.1、PySide 1.0.2、Qt 4.7.2。现在我正在构建最新的PySide,以便对其进行测试,但在最近的发行说明或bug报告中找不到任何关于shouldInterruptJavaScript的信息。在
在我的子类中重新实现shouldInterruptJavaScript有什么特别的地方吗?
在1.0.6版之后,这个问题现在已经在pysidegit主机上修复了。在
相关问题
PyPI热门下载资源包