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

Sam Myers morefigs at gmail.com
Thu Aug 21 08:37:46 BST 2014


It worked! Thanks, been trying every combo I could think of for two days!


On 21 August 2014 17:30, Phil Thompson <phil at riverbankcomputing.com> wrote:

> 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
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140821/773f9c5f/attachment.html>


More information about the PyQt mailing list