[PyQt] Can't seem to send parameter by reference using PyQt

Phil Thompson phil at riverbankcomputing.com
Thu Aug 21 08:30:03 BST 2014


On 21/08/2014 1:50 am, Sam Myers wrote:
> I'm having trouble sending a parameter by reference using dyncamicCall 
> to
> an ActiveX object. The command GetNumHWUnits should set the second
> parameter to 2, but doesn't change it. The equivalent code works in 
> LabVIEW
> so I'm reasonably confident in the command order. Any hints?
> 
> import sys
> from PyQt4 import QtGui
> from PyQt4 import QAxContainer
> from PyQt4.QtCore import QVariant
> from PyQt4.QtGui import QMainWindow, QApplication
> 
> class APTSystem(QMainWindow):
> 
>     def __init__(self):
> 
>         QMainWindow.__init__(self)
> 
>         apt = QAxContainer.QAxWidget(self)
>         self.setCentralWidget(apt)
> 
>         apt.setControl('{B74DB4BA-8C1E-4570-906E-FF65698D632E}')   # 
> system
> 
>         apt.dynamicCall('StartCtrl()')
> 
>         typ = QVariant(6)
>         num = QVariant(0)
> 
>         apt.dynamicCall('GetNumHWUnits(int, int&)', [typ, num])
> 
>         print num.toInt()   # value is always returned as zero, 
> expecting 2!
> 
>         apt.dynamicCall('StopCtrl()')
> 
> app = QtGui.QApplication(sys.argv)
> a = APTSystem()
> a.show()
> app.exec_()

The list itself is modified, try...

args = [typ, num]
apt.dynamicCall('Get...', args)
print args[1].toInt()

Phil


More information about the PyQt mailing list