[PyQt] Mixing PyQt and QtScript

Henning Schröder henning.schroeder at gmail.com
Sun Nov 11 14:38:29 GMT 2007


Hi,

perhaps someone else is interested in my experiments in mixing PyQt
with QtScript. It seems nobody else has tried it. At least Google did
not found anything. Actually it is easily possible and I can imagine
some good use cases for it.

You can find my code at http://henning.cco-ev.de/pyqtscript_py.txt

As you will see, every slot can be called like a method in QtScript.
Unfortunately PyQt currently (?) has some limitations:
  * The pyqtSignature decorator cannot be used to define a return type.
    Without that you cannot define a method or function which returns
values to QtScript
     I guess PyQt has to set typeName in QMetaMethod.
  * QScriptEngine.newFunction is not available, but I found a
workaround by using
    QScriptEngine.newQObject and some wrapper code
  * QObject.staticmethodObject() is not available and therefore
    QScriptEngine.newQMetaObject is not very useful because sometimes
you do not
     want to create an object only to get its metaobject.



-- 
Henning


More information about the PyQt mailing list