[PyQt] PyQt & ActiveX : how to pass variables with QAxContainer (by reference?)

Pierre-Henri Jouneau phjouneau at gmail.com
Tue Mar 15 19:06:01 GMT 2011


Hello,


I am trying to use the QAxContainer module with PyQt in order to control a
microscope via a COM API. But I have a problem for passing variables: there
are in the API a Set method used to put values in the microscope, and a Get
method used to retrieve values. It seems that QAxContainer try to pass
variable by reference, and this doesn’t work with python:

API = QAxContainer.QAxObject(ProgID_EMAPI)

API.dynamicCall('Initialise(QString)', "")
API.dynamicCall('Set(QString, QVariant&)', "AP_MAG",
QtCore.QVariant("9000"))    # It’s OK: AP_MAG is set to 9000 in the
microscope
value = QtCore.QVariant("")
API.dynamicCall('Get(QString, QVariant&)', "AP_MAG", value)    # Doesn’work
!!! I don’t find how to retrieve the AP_MAG value


On the other hand, everything works well with the win32com module which
passes variable as the result of a function:


API = win32com.client.Dispatch(ProgID_EMAPI)
API.Initialise("")
API.Set("AP_MAG", "9000")    # OK : AP_MAG is set to 9000
error, value = API.Get("AP_MAG", True)    # OK : get the AP_MAG in value


Does anybody have an idea how to make the QAxContainer example working?


PH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110315/3f256238/attachment.html>


More information about the PyQt mailing list