[PyQt] How to expose function accepting array of struct to D-Bus?

Evade Flow evadeflow at gmail.com
Mon Aug 6 17:15:44 BST 2012


I'm trying to write a PyQt4-based mock object for a C++ app exposed over
D-Bus with the following interface:

    Q_CLASSINFO("D-Bus Interface", "com.acme.Audio.Control")
    Q_CLASSINFO("D-Bus Introspection",
    '  <interface name="com.acme.Audio.Control">\n'
    '    <method name="echo">\n'
    '      <arg direction="in" type="s" name="phrase"/>\n'
    '      <arg direction="out" type="s" name="echoed"/>\n'
    '    </method>\n'
    '    <method name="setParams">\n'
    '      <arg direction="out" type="(i)" name="error"/>\n'
    '      <arg direction="in" type="a(iiiii)" name="audioSourceParameter"/>\n'
    '      <annotation value="QVector<AudioSourceParameters>"
name="com.trolltech.QtDBus.QtTypeName.In0"/>\n'
    '      <annotation value="Errors::ErrorCode"
name="com.trolltech.QtDBus.QtTypeName.Out0"/>\n'
    '    </method>\n'
    '  </interface>\n')

It's unclear to me how how the setParams() function should be decorated.
For the echo() function, I have:

    @pyqtSlot(str, result=str)
    def echo(self, phrase):
        return self.parent().echo(phrase)

But what should I put for setParams()? I was tempted to write:

    @pyqtSlot('a(iiiii)', result='(i)')
    def setParams(self, volume):
        return self.parent().echo(phrase)

But this results in:

TypeError: C++ type 'a(iiiii)' is not supported as a pyqtSlot type argument type

So... how does one expose a function to D-Bus that accepts an array of
structs, each containing 5 ints?


More information about the PyQt mailing list