PyQT 打开一个带有 JS 警报的网页会弹出 SegFault。如何解决这个问题?
我正在学习PyQT编程,当我尝试一个简单的测试时,我遇到了分段错误,这是我的代码pop.py:
#! /usr/bin/python
import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QUrl
from PyQt4.QtWebKit import QWebView
app = QApplication(sys.argv)
v = QWebView()
v.load(QUrl("http://127.0.0.1/j.html"))
v.show()
app.exec_()
我在127.0.0.1启动了一个Apache服务器进行测试。这里是j.html:
<html><script>alert("I am here");</script>
<body>Hello World</body>
</html>
我启动pop.py,打开一个窗口,javascript弹出警报对话框,我单击“确定”,然后pop.py将完全并得到“分段错误”
我尝试了PySide,得到相同的结果。如果html中没有JS警报,就可以了。这是 QT 的错误还是我错过了什么?
我使用 python 2.6.6、python-qt4 4.8.3、libqtwebkit4 2.1.0 在 Debian 上工作,
我还尝试使用 PyQt4-4.8.3、python 2.7.1 来使用 Fedora 15,同样的问题
任何建议、搜索线索都会有所帮助。谢谢
I am learning PyQT programing, and when I try a simple test, I get Segmentation fault, here is my code pop.py:
#! /usr/bin/python
import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QUrl
from PyQt4.QtWebKit import QWebView
app = QApplication(sys.argv)
v = QWebView()
v.load(QUrl("http://127.0.0.1/j.html"))
v.show()
app.exec_()
I started an Apache server at 127.0.0.1 for testing. And here is j.html:
<html><script>alert("I am here");</script>
<body>Hello World</body>
</html>
I start the pop.py, open a window, javascript popup alert dialog, I click the OK, then pop.py will quite and get "Segmentation fault"
I tried PySide, get same result. If not JS alert in html, will be OK. Is this a bug of QT or I missed something?
I worked on Debian with python 2.6.6, python-qt4 4.8.3, libqtwebkit4 2.1.0
I also tried Fedora 15 with PyQt4-4.8.3, python 2.7.1, same issue
Any suggestion, clue for searching will be helpful. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这适用于上面给出的测试用例 正如
上面评论中所述, http://developer .qt.nokia.com/forums/viewthread/4760 解释了该错误,据报告已从 https://bugs.webkit.org/show_bug.cgi?id=57414 并且是可能包含在 Qt 4.7.2 中。
This works with the test case given above for
As noted above in the comments, http://developer.qt.nokia.com/forums/viewthread/4760 explains the bug and it is reported as fixed from https://bugs.webkit.org/show_bug.cgi?id=57414 and was probably included in Qt 4.7.2.