23

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

gfortune
  • 2,589
  • 14
  • 14
PasteBT
  • 2,128
  • 16
  • 17
  • 2
    I try to use cpp coding with QT, bypass python, same issue. – PasteBT Dec 03 '11 at 00:10
  • 8
    I found there is a bug report for this issue: https://bugs.webkit.org/show_bug.cgi?id=57414 , here is code: http://developer.qt.nokia.com/forums/viewthread/4760 – PasteBT Dec 03 '11 at 00:23
  • 1
    Yep, seems like you found the answer on your own. A trunk version of webkit will work, but the one shipping seems to have that problem. – Martin Samson Dec 09 '11 at 13:54
  • 9
    You can answer your own questions (and in this case, should!) – Bryce Jan 11 '12 at 07:06

1 Answers1

3

This works with the test case given above for

Qt:     4.7.2
PyQt:   4.8.3 or PySide 1.0.1
Python: 2.7.1

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.

gfortune
  • 2,589
  • 14
  • 14