[PyQt] PyQt Release Plans and Qt v4.4 Support

Henning Schröder henning.schroeder at gmail.com
Fri Apr 18 04:21:25 BST 2008

Ok I got the snapshot working by changing "void *a0" into "uchar *a0"
for QFile::unwrap :-)

I was playing a litte bit with QtWebKit after reading
There is an example which shows that is possible that a webpage can
interact with QObjects by exposing slots to JavaScript.

I can do nearly the same with the pyqtSignature decorator, which is
cool. Unfortunately this only works one way because I cannot define a
result type.
Could this be added to the decorator?

Here is an example:

#!/usr/bin/env python
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

class PythonJS(QObject):

    def __init__(self):
        QObject.__init__(self, qApp)

    def alert(self, msg):
        print "alert called"
        print msg

    def fortune(self):
        print "fortune called"
        return 23 # XXX: does not work

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    browser = QWebView()
       <script>function fortune() { return 42; }</script>
       <h1>Hello, world</h1>
       <input type="button" value="Click JS!" onClick="alert('hi ' +
       <input type="button" value="Click PY!"
onClick="python.alert('hi ' + python.fortune())"/>
    frame = browser.page().mainFrame()
    frame.addToJavaScriptWindowObject("python", PythonJS())

More information about the PyQt mailing list